AVAudioSession gets interrupted when closing a window

I have a visionOS app that plays audio using AVAudioEngine and presents both a window and an immersive space. If I close the window, the audio session gets interrupted and attempting to restart the session and audio engine has no effect. I need to dismiss the app, then reopen it, which reopens the main window, in order for audio to start playing again.

This is in all visionOS 2 betas. Note that I have background audio enabled for my app.

We have a similar issue but with AVAudioPlayer. Dismissing then reopening immersive space / window causes the audio to stop, and attempting to call play() again has no effect.

Hey @trilorez,

This sounds like a bug. It would be great if you could file a bug report for this issue using Feedback Assistant.

@NSCruiser I'm not seeing that same behavior. I am experiencing the behavior in which the audio stops when the WindowGroup is closed and the ImmersiveSpace is still open. But calling .play() again does result in the audio resuming. In order to investigate the play() method not having any effect could you open a bug report including a sample project that replicates the issue and post the FB number here once you do.

Bug Reporting: How and Why? has tips on creating your bug report.

Thanks!

Michael

We seem to be having the same issue as well, whenever the window goes into an inactive state before foreground, the audio session gets interrupted. if you have only one window and you close it from the system button, it goes into inactive (causing the session to be interrupted) and then foreground. Closing it programmatically (dismiss window Action) is handled differently as then when observing the scene phases, the window goes directly into foreground.

Also if you open window A, and then Window B and then close window B and then A. Interrupts the Audio. In this case, Window B goes into background, but window A goes to Inactive-> Background.

However closing window A while B is open and then closing window B does not interrupt it. both windows go into Background state directly.

which makes me think that it is the inactive state that is causing this interruption.

AVAudioSession gets interrupted when closing a window
 
 
Q