6

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:

enter image description here

If I use AVAudioPlayer to play that sound it's ok. I can't understand what is the problem with AVAudioEngine. Any advices?

Nikunj
  • 654
  • 3
  • 12
  • 22
Thomas
  • 177
  • 2
  • 9

1 Answers1

2

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!

M. Adeel Khalid
  • 1,770
  • 2
  • 21
  • 24
Takatomo
  • 43
  • 5