[iOS] No audio on a call answered from CallKit when configureAudioSession is false
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
调研方向
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_notification1.7.2 (git ref2ec78303dbc6fe8043e104b4cd378d56b2159a4e)- 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, nomixWithOthers)
Steps to reproduce
- Set
configureAudioSession: falseinStreamVideoPushConfiguration.ios. - Put the callee app in the background. No call has been joined yet, so WebRTC hasn't configured
AVAudioSessionand its category is still the default. - Ring the callee from another device.
- 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 noActionCallToggleAudioSessionevent 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)andsetPreferredIOBufferDuration(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:
- Always set a recording category before fulfilling the answer. When
configureAudioSessionis false, still setplayAndRecord(with a configurable mode and options) inCXAnswerCallAction, withoutsetActive, and leave the rest to the app. - Per-direction setting. For example
configureAudioSessionForIncoming/configureAudioSessionForOutgoing, so the plugin can configure answered calls only. - Configurable options. Let
IOSPushConfigurationtake the category options (and skip the sample rate, buffer duration andsetActivecalls), soconfigureAudioSession: truecan match the app's WebRTC configuration. - Document it. At least note that
configureAudioSession: falserequires 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 小时
- 30 天内合并 PR
- 142
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
GetStream/stream-video-flutter 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 55/100
GetStream/stream-video-flutter#1661 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
GetStream/stream-video-flutter#1621 ·
维护者通常 2 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
GetStream/stream-video-flutter#1615 · 1 条评论 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 52/100
GetStream/stream-video-flutter#1535 · 2 条评论 ·
维护者通常 2 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
GetStream/stream-video-flutter#1430 · 1 条评论 ·
维护者通常 2 天内回复
查看 GetStream/stream-video-flutter 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
wger-project/flutter#1428 · 1 条评论 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
ccch1mneyyy/dsh-Go#2051 ·
维护者通常 1 天内回复
-
documentation good first issue help wanted
难度 2/5 1-3 小时 新手友好度 78/100
younghwan91/fin-checkup#126 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 66/100
rajput-hemant/calculator#214 ·
-
duration: small priority: medium type: bug
难度 2/5 1 小时以内 新手友好度 78/100
duobaseio/forui#1254 · 1 条评论 ·
维护者通常 1 天内回复