Saturday, July 18, 2015

Your App Stutters in iOS 9?

Did you try your app out on iOS 9 and discover that the audio or UI was stuttering?

I just spent a few hours with Instruments and an iOS 9 beta (the July 8, 2015 iOS 9 beta 13A4293g) trying to figure out why Modern Metronome was skipping a beat. Timers would sometimes fail to start an animation at the correct time, and some Audio Queue requests weren't getting fired at all.

Funny, everything worked fine in iOS 8.

I optimized several methods that seemed to be problematic, but the stuttering remained. I finally got down to these two calls:

[AVAudioSession setCategory:withOptions:error:]
[AVAudioSession setActive:error:]

It turned out that I was calling them both every time that I created an Audio Queue. On iOS 8, these repeated calls didn't have any noticeable effect. On the iOS 9 beta, they have larger performance consequences than Instruments implies.


I moved those two lines so they would only get called once, and my stuttering disappeared. I hope this helps you!