Title: AVAudioSession interrupted with no .ended when the window changes while an ImmersiveSpace is open
Hi,
I'm seeing an issue where an active voice call (mic capture + playback) goes silent as soon as the app enters its immersive experience. The system posts AVAudioSession.interruptionNotification with type .began, but .ended never arrives while the app stays in the foreground, so the audio never resumes on its own. Audio only comes back after the app goes inactive and active again (for example after leaving the immersive space).
This looks like the same issue reported in https://developer.apple.com/forums/thread/761721 (2024), and it still reproduces on visionOS 26 and 27.
Setup:
App with a WindowGroup and an ImmersiveSpace.
Voice runs on a WebRTC stack (LiveKit, AVAudioEngine-based) on top of AVAudioSession, configured as:
category .playAndRecord, mode .videoChat, options [.mixWithOthers, .allowBluetoothHFP, .allowBluetoothA2DP, .allowAirPlay], then setActive(true).
When the immersive space opens, an ARKitSession runs with WorldTrackingProvider, HandTrackingProvider and SharedCoordinateSpaceProvider.
Steps to Reproduce:
Start a voice call from the main window. Mic capture and playback both work.
Open the ImmersiveSpace and replace the main window with another window (open the new window, dismiss the main one).
Shortly after the space opens, interruptionNotification arrives with type .began and reason .default (0).
The audio engine stops. Mic capture and playback both go silent.
Expected: Audio keeps running when the window changes. If the system has to interrupt the session, .ended is posted so the app can resume.
Actual: .began arrives with no matching .ended while the app remains in the foreground. Audio stays silent until the app goes inactive and active again. At that point .ended arrives with .shouldResume and the engine starts again.
The same interruption sometimes hits the very first microphone start right after the session is activated, so the start times out.
Nothing else in the app activates or deactivates the audio session at that point.
Observation code:
NotificationCenter.default.addObserver(
forName: AVAudioSession.interruptionNotification, object: nil, queue: .main
) { note in
let type = note.userInfo?[AVAudioSessionInterruptionTypeKey] as? UInt
let reason = note.userInfo?[AVAudioSessionInterruptionReasonKey] as? UInt
print("interruption type=\(String(describing: type)) reason=\(String(describing: reason))")
// Logged: type=1 (.began), reason=0 (.default). No type=0 (.ended) while the app stays active.
}Current workaround:
On every interruptionNotification, and again on UIApplication.didBecomeActiveNotification, call setActive(true) and restart the audio engine if it isn't running. This restores audio while the immersive space stays open.
Device: Apple Vision Pro
visionOS version: visionOS 27.2 (24N120), also seen on visionOS 26.5 (23O471)
Xcode version: Version 27.0 (27A266a)
Questions:
Is the app's audio session expected to be interrupted when a window closes or is replaced while an ImmersiveSpace is open?
If so, why is no .ended posted while the app remains active, and is reactivating the session and restarting the engine the recommended way to resume?
Thank you!
0
0
56