[iOS] No audio on a call answered from CallKit when configureAudioSession is false

オープン
#1,652 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
dart, flutter, ios

調査の方向性

Start by reading the iOS push notification plugin’s CallKit answer handling and its configureAudioSession() implementation, especially provider(_:perform: CXAnswerCallAction) and provider(_:didActivate:). The report identifies the missing recording category when configuration is disabled, but leaves the preferred fix open among several options. Done means an incoming CallKit answer activates audio with configureAudioSession: false while leaving session activation to the app; check existing iOS CallKit and audio session tests, if present.

索引モデルが issue の本文から書いたものです。

説明

Summary

stream_video_push_notification either fully manages AVAudioSession for every CallKit call (configureAudioSession: true) or does nothing at all (false). An app that lets WebRTC own the audio session has to pass false. Then a call answered on the CallKit screen gets no audio in either direction: CallKit never activates the audio session, because the category still can't record when the call is answered.

Environment

  • stream_video_flutter / stream_video_push_notification 1.7.2 (git ref 2ec78303dbc6fe8043e104b4cd378d56b2159a4e)
  • iOS 26.6, iPhone 15 Pro (physical device)
  • Ringing call (getOrCreate(ringing: true)), received as a VoIP push (APN provider) and shown by the plugin with CallKit
  • IOSPushConfiguration(configureAudioSession: false, ...)
  • Audio session configured through AudioConfigurationPolicy.custom (playAndRecord / voiceChat, no mixWithOthers)

Steps to reproduce

  1. Set configureAudioSession: false in StreamVideoPushConfiguration.ios.
  2. Put the callee app in the background. No call has been joined yet, so WebRTC hasn't configured AVAudioSession and its category is still the default.
  3. Ring the callee from another device.
  4. Answer on the CallKit screen, then accept and join the call in the app (consumeIncomingCall → accept → join).

Expected

CallKit activates the audio session (provider(_:didActivate:)), and the call has audio both ways.

Actual

  • The call joins and both peer connections reach connected. The remote audio track is received, and the SFU reports the remote participant speaking.
  • provider(_:didActivate:) is never called after the answer, and no ActionCallToggleAudioSession event arrives.
  • Neither side hears anything.

Cause

When the call is answered, the audio session category is still the app's default, which can't record. With configureAudioSession: false, the plugin's configureAudioSession() is a no-op in both provider(_:perform: CXAnswerCallAction) and provider(_:didActivate:). So nothing sets playAndRecord before the answer action is fulfilled, and CallKit doesn't activate the session. Apple expects the app to configure the category before fulfilling CXAnswerCallAction.

Outgoing calls aren't affected: the app joins first, which lets WebRTC configure the session, and only then reports the call to CallKit (startOutgoingCall).

This is confirmed indirectly: an extra CXAnswerCallAction issued later, after WebRTC had set playAndRecord, did trigger didActivate, and audio came up.

Why configureAudioSession: true isn't an option

With true, the plugin applies a fixed configuration to every call, outgoing included, which overrides the one WebRTC applies:

  • options are hard-coded: .allowBluetoothA2DP, .duckOthers, .allowBluetooth (no way to drop ducking or add .allowAirPlay)
  • setPreferredSampleRate(44100) and setPreferredIOBufferDuration(0.005)
  • setActive(true) is called by the plugin, although with CallKit the system is meant to activate the session

In our case this broke the audio route of outgoing calls, for example the CallKit speaker button. So false is the only workable setting, and incoming calls then have no audio.

Workaround

We observe CallKit from the app and set the category as soon as an incoming call starts ringing. We don't activate the session ourselves:

final class IncomingCallAudioSession: NSObject, CXCallObserverDelegate {
    private let callObserver = CXCallObserver()

    override init() {
        super.init()
        callObserver.setDelegate(self, queue: .main)
    }

    func callObserver(_ callObserver: CXCallObserver, callChanged call: CXCall) {
        guard !call.isOutgoing, !call.hasConnected, !call.hasEnded else { return }
        let rtc = RTCAudioSession.sharedInstance()
        guard rtc.category != AVAudioSession.Category.playAndRecord.rawValue else { return }
        rtc.lockForConfiguration()
        defer { rtc.unlockForConfiguration() }
        try? rtc.setCategory(
            .playAndRecord,
            mode: .voiceChat,
            options: [.allowBluetoothHFP, .allowBluetoothA2DP, .allowAirPlay]
        )
    }
}

It's created in application(_:didFinishLaunchingWithOptions:). An app launched by a VoIP push may not have a Flutter engine yet when the call rings, so it can't live in a Flutter plugin.

Proposed fix

Any of these would remove the need for the workaround:

  1. Always set a recording category before fulfilling the answer. When configureAudioSession is false, still set playAndRecord (with a configurable mode and options) in CXAnswerCallAction, without setActive, and leave the rest to the app.
  2. Per-direction setting. For example configureAudioSessionForIncoming / configureAudioSessionForOutgoing, so the plugin can configure answered calls only.
  3. Configurable options. Let IOSPushConfiguration take the category options (and skip the sample rate, buffer duration and setActive calls), so configureAudioSession: true can match the app's WebRTC configuration.
  4. Document it. At least note that configureAudioSession: false requires the app to set a recording category before a CallKit answer.

Related plugin behaviour we ran into

Calling setCallConnected on an incoming call that was already answered requests another CXAnswerCallAction (StreamCallKitCallController.connectedCall). That emits a second ActionCallAccept for the same call. It's easy to hit when an app marks every call connected the same way, as you would for outgoing calls. Ignoring incoming calls in connectedCall, or documenting that it's for outgoing calls only, would help.

主要言語
Dart
スター
79
フォーク
55
平均マージ
2日 12時間
マージ済み PR(30日)
142

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GetStream/stream-video-flutter のほかの issue

GetStream/stream-video-flutter の issue をすべて見る

似ている issue

Dart の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。