Hi all,
We have received a number of crash reports from the app. They all look similar. The call [AVAudioSession currentRoute] is on the top of each crashed stack:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000c0b25beb8
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread: 14
...
Thread 14 name:
Thread 14 Crashed:
0 libobjc.A.dylib objc_msgSend + 16
1 AVFAudio -[AVAudioSession currentRoute] + 140 (AVAudioSession.mm:1715)
...
We found that the crash happens in the handler of AVAudioSessionRouteChangeNotification notification. In this handler we are posting an asyncronous call on our custom serial queue, where we are getting the current route and enumerating through all the outputs.
- (instancetype)init
{
if (self = [super init])
{
_commandsQueue = dispatch_queue_create("com.app.commandsQueue", DISPATCH_QUEUE_SERIAL);
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRouteChanged:)
name:AVAudioSessionRouteChangeNotification
object:nil];
}
return self;
}
- (void)handleRouteChanged:(NSNotification *)notification
{
dispatch_async(self.commandsQueue, ^{
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription* currentRoute = audioSession.currentRoute;
for (AVAudioSessionPortDescription *outputPort in currentRoute.outputs)
{
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay])
{
// updating dictionary with status
}
}
});
}
We are not able to reproduce the issue and we do not know the exact scenario. We played a lot with different route change scenarios, but we observed no crashes.
Does anyone have a idea about the root cause of this crash?
Thanks,
Mike