I uploaded an archive on app store and am getting crash when I 'm trying to play an intro sound. I'm using AVAudioEngine
to play the sound. When I compile and run code through Xcode everything works fine. When I upload on TestFlight and try to run my app as an internal tester my app crashes. The crash report is:
If I use AVAudioPlayer
to play that sound it's ok. I can't understand what is the problem with AVAudioEngine
. Any advices?
I faced the same exception only in the release build of my app and specific to iPhone7. The exception seems to occur at a changing point of audio session category. In my case, changing from
AVAudioSessionCategorySoloAmbient
to
AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.defaultToSpeaker
I found a workaround which works at least just for me.
The following article https://forums.developer.apple.com/thread/65656 tells that this kind of exception occurs at initialization of multiple input audio unit.
In order to prevent initialization of multiple input audio unit, I added the following codes before the change of audio session category
AudioOutputUnitStop((engine.inputNode?.audioUnit)!)
AudioUnitUninitialize((engine.inputNode?.audioUnit)!)
engine is the instance of AVAudioEngine
.
I hope it will help you guys!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With