fix(ios): recover AVAudioSession after phone call interruption#1094
Open
ashifali3147 wants to merge 2 commits into
Open
fix(ios): recover AVAudioSession after phone call interruption#1094ashifali3147 wants to merge 2 commits into
ashifali3147 wants to merge 2 commits into
Conversation
iOS 16+ does not reliably fire AVAudioSessionInterruptionTypeEnded for cellular calls, leaving WebRTC's audio unit dormant while the mic appears enabled. This fix handles recovery via three notification sources: interruptionNotification, didBecomeActiveNotification (app backgrounded during call), and routeChangeNotification (Dynamic Island / foreground calls). Recovery only clears the interrupted flag when RTCAudioSession .setActive succeeds, so mid-call route changes retry rather than resetting state prematurely. Two new RoomEvents (AudioSessionInterruptedEvent, AudioSessionResumedEvent) let apps react in Flutter — e.g. muting the local participant while interrupted and re-enabling the mic button on recovery.
… recovery RTCAudioSession.setActive is bridged as a throwing function in Swift — using the Objective-C NSError pointer style caused a compilation error. Replace with do/try/catch matching the existing setConfiguration pattern in LiveKitPlugin.swift.
Contributor
Author
|
Windows build failure is pre-existing and unrelated to this PR — same failure appears on other recent PRs (e.g. 1091 ). All other checks pass. |
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.
Fix: Reliable Audio Session Recovery for Cellular Calls on iOS 16+
Problem
iOS 16+ does not reliably fire
AVAudioSessionInterruptionTypeEndedfor cellular calls, leaving WebRTC's audio unit dormant despite the mic appearing enabled. This causes one-way audio or complete audio loss.Affected scenarios:
Solution
Implement multi-source interrupt recovery using three notification channels:
Recovery clears the interrupted flag only when
RTCAudioSession.setActive()succeeds, enabling automatic retry on failures.Changes
New RoomEvents
Flutter Example
Key Benefits
Testing
Fixes audio loss on iOS 16+ during cellular call interruptions.