We have noticed that sometimes our app spends too much time in the first call of AVAudioSession.sharedInstance
and [AVAudioSession setCategory:error:]
which we call on app's initialization (during init of apps delegate). I am not sure if the app is stuck in these calls or it simply takes too much time to complete.
This probably causes the app to crash due to main thread watchdog.
Would it be safe to move these calls to a separate thread?
It's unlikely that calling setCategory:error:
is itself going to trigger the watchdog, though it's possible that if you're doing a lot of other work at initialization time this might send your usage "over the top".
Anyway, app delegate initialization seems way to early to set up your audio session. You should wait at least until the "didFinishLaunching" callback, or — better still, as recommended by the note in the documentation — wait until you first need to play or record some audio, so that you don't interrupt other app's audio until/unless you need to.