AVAudioSession currentRoute crash

We have received several crash reports from the application. They are all alike. The call to [AVAudioSession currentRoute] is at the top of each split 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 occurs in the AVAudioSessionRouteChangeNotification notification handler. In this handler, we send an asynchronous call to our custom sequential queue, where we get the current route and list all 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 cannot reproduce the problem and we do not know the exact scenario. We played a lot with different rerouting scenarios, but we didn't see any glitches. Does anyone have any idea of ​​any possible root cause for this failure?

+3


source to share





All Articles