Repository navigation
Conversation
Starting a second `Recorder` of the same `CameraVideoOutput` while the first one is recording must reject. On Android this currently crashes the app with `IllegalStateException: A recording is already in progress`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CameraX `PendingRecording.start()` throws `IllegalStateException` synchronously
when the output's `Recorder` already has an active or pending recording. That
happens when a second `Recorder` of the same `CameraVideoOutput` is started
while the first one is still recording. The throw escaped the recorder's
executor and crashed the app. Reject the `startRecording()` promise instead,
which matches iOS ("Active recording already in progress!").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@radko93 is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Android, starting a second
Recorderof the sameCameraVideoOutputwhile the first one is still recording crashes the app.All Recorders of one output share a single CameraX
Recorder. When it already has an active or pending recording,PendingRecording.start()throwsIllegalStateExceptionsynchronously.HybridVideoRecorder.startRecordingcalls it insideexecutor.executewithout a catch, so the exception escapes the executor and kills the process. The per-Recorder "Active recording already in progress!" guard does not help, because each Recorder has its own executor and state.iOS already handles this: it checks
videoOutput.isRecordingand rejects the promise with "Active recording already in progress!".We see this crash in production (a dozen per month in our app).
Reproduction
The first commit adds a harness test to
visioncamera.video.harness.ts: start Recorder 1, then start Recorder 2 of the same output, expect the second start to reject and the first recording to finish normally.On
main(API 30 emulator, example app) the test kills the app:Run it with:
Change
Catch
IllegalStateExceptionaroundpendingRecording.start(...)and reject thestartRecording()promise, like iOS does. Errors still propagate. Most of the diff is re-indentation; hiding whitespace shows the actual change.Verification
main, passes with the fix (API 30 emulator).visioncamera.video.harness.tson an API 35 emulator: everything passes except the two "records at the device's maximum/minimum supported video resolution" tests, which fail the same way onmain(the emulated camera always records 720p).bun run lint-kotlin, biome andtscare clean.Generated with Claude Code