FMOD iOS App Hang on Resume: "The app was terminated while unresponsive"

Hi everyone,

I’m encountering a persistent issue with FMOD in my Unity project on iOS. When the app resumes from the background, the OS occasionally terminates it with the error: “The app was terminated while unresponsive.”

I suspect this is related to how I’m handling AVAudioSession reactivation. During resume, if setActive:TRUE fails with AVAudioSessionErrorCodeCannotStartPlaying, I am currently using a while loop to retry activation (as shown in the code below). I suspect this blocking loop is triggering the iOS Watchdog to kill the app.

Hi,

Can I get some more info from you? Specifically:

  • Your FMOD version
  • Your Unity version
  • You iOS version
  • What Category your AVAudioSession is using

Thanks!

Hi, here is the version information:

Unity version:6000.3.7f1
Unity_Fmod :2.03.11
IPhone 17 Pro max ,IOS 26.4
User-reported crash log from backend. Not sure what the AVAudioSession category is.

I would really appreciate it if you could help locate the issue.

Thanks for the additional info!

At the point of the usleep(), FMOD is unable to set the AVAudioSession as active due to circumstances outside of its control (i.e. some other app taking priority), and since the AVAudioSession is handled by iOS, it’s not really possible for FMOD to do anything else. I’d recommend modifying that section of the code to use periodically attempt to set the session as active without using usleep - the NSTimer class might be worth looking into.

Thank you for your response!

I would like to provide some additional information. The -usleep method is actually in the Objective-C code generated by Unity when exporting to Xcode, rather than in our source code, so I am unsure how to change it. Could you please clarify how to call the “… use periodically attempt to set the session…” solution you suggested?

Thank you for your help!

The Objective-C code you’re looking at is actually code that comes with the FMOD for Unity integration, specifically for handling suspending/resuming and interruptions on iOS. You can find it at ./Assets/Plugins/FMOD/platform_ios.mm.

You should take a look at deleting the entire while loop around the usleep call a d replacing it with an NSTimer, as previously mentioned. Here’s a theoretical example, which may or may not suit your needs:

[NSTimer scheduledTimerWithTimeInterval:.01 repeats:YES block:^(NSTimer * _Nonnull timer) {
    if ([[AVAudioSession sharedInstance] setActive:TRUE error:nil]){
        [timer invalidate];
    }
}];