Skip to content

iOS: keep call audio after audio session changes - #101

Closed
Magmusacy wants to merge 2 commits into
masterfrom
fce-3912
Closed

Magmusacy wants to merge 2 commits into
masterfrom
fce-3912

Conversation

@Magmusacy

@Magmusacy Magmusacy commented Oct 6, 2026 •

Copy link
Copy Markdown

Problem

On iOS, a call's microphone and playout can go silent mid-call while video keeps working; only rejoining helps. Two triggers:

  • Other code deactivates the shared AVAudioSession, e.g. expo-audio after playing a sound.
  • CallKit deactivates and reactivates the session, e.g. a call put on hold and resumed ("Hold & Accept").

In both cases WebRTC's audio unit stops, but WebRTC keeps it marked as started and never restarts it.

Change

Bumps FishjamWebRTC to 124.0.2.4, which restarts the audio unit when it is stopped by anything other than WebRTC: right away if the session is still active (other code deactivated it), or when CallKit activates the session again (hold → resume). See fishjam-cloud/webrtc#3. No changes in this repo's native code.

Apps can avoid even the short gap after a sound by creating expo-audio players with keepAudioSessionActive: true.

Testing

Tested on an iPhone 16 with fishjam-chat and a browser peer (this branch + a local 124.0.2.4 build):

  • expo-audio sound / setIsAudioActiveAsync(false) during a call: audio returns after ~0.5 s, also with the app in the background.
  • CallKit hold → unhold: silent while held, back ~1 s after unhold.
  • Mic toggle, background/foreground, leave/rejoin: no regressions.

Draft until FishjamWebRTC 124.0.2.4 is released; the pod doesn't resolve before that.

@linear

linear Bot commented Oct 6, 2026

Copy link
Copy Markdown

FCE-3912

@Magmusacy
Magmusacy marked this pull request as ready for review October 6, 2026 17:44
Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new implementation is missing from the Xcode target and is not guarded against macOS compilation.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Improves iOS call-audio resilience after external audio-session changes.

Changes:

  • Adds an AVAudioSession deactivation guard.
  • Activates the guard during WebRTC initialization.
  • Updates FishjamWebRTC for CallKit recovery.
File Description
AudioSessionGuard.h Declares the guard API.
AudioSessionGuard.m Implements deactivation interception.
WebRTCModule.m Enables the guard on iOS.
FishjamReactNativeWebrtc.podspec Bumps the WebRTC dependency.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


#pragma mark - AVAudioSession (AudioSessionGuard)

@implementation AVAudioSession (AudioSessionGuard)
RTCInitFieldTrialDictionary(fieldTrials);

#if TARGET_OS_IOS
[AudioSessionGuard activate];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants