Repository navigation
Conversation
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
|
Device test results: Tested on an iPhone 17 Pro running iOS 27.0.1, with simultaneous microphone publishing and remote audio playback, the default |
|
Closing this for now. The session configuration comes back after the reset, but the audio engine stays stopped on both main and this branch, so this change alone doesn't bring audio back. Restoring the engine needs a separate look, and the results above may help with that. |
When media services are reset, iOS posts
AVAudioSession.mediaServicesWereResetNotification. You can trigger this on a device with Settings > Developer > Reset Media Services, and it also happens when the audio server crashes. After a reset the audio session configuration is gone, and Apple's documentation for this notification says apps need to configure the session again.AudioSessionEngineObserveronly configures the session when its requirements change, andupdateRequirementsreturns early when they are the same. If audio comes back with the same requirements after a reset, the session keeps the system default category and mode, and it may stay inactive, until the requirements change again.Changes
mediaServicesWereResetNotificationon the sharedAVAudioSession, the same waySoundPlayerobserves engine configuration changes.configureIfNeededfrom a state with no requirements. This sets the category, mode and options again and activates the session. Errors are logged.stateBeforeMediaServicesReset(_:), with unit tests.This only handles media services resets. Interruption handling (#1020, #886) is a bigger topic and isn't changed here. The early return in
updateRequirementsstays: it avoids extra work in the normal path, and a reset is the one case where the same requirements have to be applied again.Test
AudioSessionCategorySelectionTests, including the new reset cases, pass on the iOS Simulator.AVAudioSession.sharedInstance().categoryandmodematch the SDK selection again, and the session is active.