Repository navigation
Conversation
cloudwebrtc
requested review from
davidliu
and
a balanced review from Copilot
October 27, 2026 07:37
There was a problem hiding this comment.
🟢 Approval recommended
The narrow failure-path reset aligns Java state with native failure handling under the existing lock, with no identified blocking issues.
No open issues 🎉
What changed in this PR
Fixes Android audio recording recovery after native initialization fails, allowing later calls to retry on the same audio device module.
Changes:
- Clears
nativeCalledInitRecordingwheninitRecordingImpl()returns a failure. - Preserves successful initialization behavior and returns the original result.
| File | Description |
|---|---|
| sdk/android/src/java/org/webrtc/audio/WebRtcAudioRecord.java | Resets the native initialization flag on failure so subsequent attempts are not rejected as duplicate initialization. |
Review effort: Balanced
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.
initRecording()setsnativeCalledInitRecordingbefore it callsinitRecordingImpl(). If that call fails, the flag stays true. The only reset is instopRecording(), and native never calls it after a failed init:AudioRecordJni::StopRecording()returns early whileinitialized_is false. From then on everyInitRecordingon the same ADM fails with "InitRecording called twice without StopRecording." and the mic stays silent until the process restarts.This resets the flag when an init started by native fails.
Refs #315, same root cause, crash variant through prewarm.
Reproduce: Android emulator. Deny
RECORD_AUDIOand start a call. Grant it and start another call on the same ADM. The second call fails with "called twice" and sends 0 packets.