Skip to content

Commit

Permalink
Debug crash while cancelling video message recording
Browse files Browse the repository at this point in the history
  • Loading branch information
vkryl committed Dec 3, 2023
1 parent 8c8748e commit 219c248
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1450,11 +1450,15 @@ private void setRoundGenerationFile (final TdApi.File file) {
private int savedRoundDurationSeconds;

private void startVideoRecording () {
if (this.recordingRoundVideo)
throw new IllegalStateException();
this.recordingRoundVideo = true;
ownedCamera.getLegacyManager().requestRoundVideoCapture(roundKey, this, roundOutputPath);
}

private void finishVideoRecording (int closeMode) {
if (!this.recordingRoundVideo)
throw new IllegalStateException();
this.recordingRoundVideo = false;
this.roundCloseMode = closeMode;
final boolean needResult = closeMode != CLOSE_MODE_CANCEL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import android.widget.TextView;

import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

Expand Down Expand Up @@ -285,9 +286,12 @@ private void setForceLegacy (boolean forceLegacy) {
}
}

private Throwable debugDestroy;

public void checkLegacyMode () {
if (contentView != null && isLegacy() != needLegacy()) {
if (manager != null) {
debugDestroy = Log.generateException();
contentView.removeView(this.manager.getView());
manager.destroy();
manager = null;
Expand Down Expand Up @@ -330,11 +334,21 @@ public void setUseFastInitialization (boolean useFastInitialization) {
}
}

public CameraManager<?> getManager () {
private void ensureManager () {
if (manager == null) {
if (debugDestroy != null)
throw new IllegalStateException(debugDestroy);
throw new IllegalStateException();
}
}

public @NonNull CameraManager<?> getManager () {
ensureManager();
return manager;
}

public CameraManagerLegacy getLegacyManager () {
public @NonNull CameraManagerLegacy getLegacyManager () {
ensureManager();
return (CameraManagerLegacy) manager;
}

Expand Down

0 comments on commit 219c248

Please sign in to comment.