Audio Interruption Not Being Intercepted in AVAudioSession with Classification

Hi everyone,

I’m experiencing an issue where audio interruptions (e.g., phone calls) are not being intercepted while running sound classification in an app that uses the AVAudioSession. Classification works fine, but interruptions aren’t handled, even though I’ve followed Apple’s guidelines on handling audio interruptions [1_Document].

The classification was initially based on [2_Classifer], where it worked perfectly. However, when I adopted classification in a more camera-focused app using [3_Cam], the interruption behavior stopped working. The classification setup is functioning with [3_Cam], but audio interruptions are not triggered.

The listener is invoked before starting sound analysis as suggested in [2_Classifier].

startListeningForAudioSessionInterruptions()
try startAnalyzing([(request, observer)])

FYI, one change I have made for classifications is following. This works fine in all cases.

// try audioSession.setCategory(.record, mode: .default)

try audioSession.setCategory(.playAndRecord, mode: .default, options: [.defaultToSpeaker, .allowBluetooth])

I suspect the issue might be related to the AVAudioSession configuration or how the app handles recording and playback together. Is there anything else I should check related to AVAudioSession? Are there additional APIs I could use to pre-check or better handle audio interruptions?

Any suggestions or guidance would be greatly appreciated!

Platform: Swift 5, Xcode 16, iOS 18.

References:

  1. Document
  2. Classifier
  3. Cam

Best Regards

Hello @Blume, thank you for your post. Our engineering teams need to investigate this issue, as resolution may involve changes to Apple's software. I'd greatly appreciate it if you could open a bug report, include a sysdiagnose, and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

Audio Interruption Not Being Intercepted in AVAudioSession with Classification
 
 
Q