Fix android crash when recording repeated sessions#1101
Open
Traviskn wants to merge 2 commits into
Open
Conversation
Two related fixes for repeated start/stop/save recording cycles on Android when using file output (FFmpeg) together with callback output: - AndroidAudioRecorder::stop() moved the data callback out of the recorder, so the next start() with callback output enabled failed with "Callback output is unavailable". Copy the shared_ptr instead to keep the JS callback subscription registered across sessions. - FFmpegAudioFileWriter::closeFile() destroyed the TaskOffloader only after draining the FIFO and encoder, leaving the offloader thread free to race with finalization and crash during stop/save. Reset it first so all offloaded writes complete before the file is finalized. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Introduced changes
Symptoms
I hit an Android-only crash/freeze and follow-on callback-output failure when using
AudioRecorderwith file output (.m4a, FFmpeg enabled) and callback output across repeated recording sessions.In my app, the first recording could start, stop, and save, but repeated recording sessions exposed two related Android failures:
The user-facing results were either a frozen/crashed app, a recording that could not be saved, or a saved recording with
0:00captured duration.Validation
After applying this patch locally, I tested repeated recordings on a physical Android device:
Results:
Callback output is unavailablelogSIGABRT,SIGSEGV, orcrash_dumpThis PR fixes both the original crash/freeze and the later callback-output failure.
Checklist