Very Rare Intermittent Crash in AVFoundation.AVAudioPlayerNode.play() (AVAudioPlayerNode.mm:660)

27 Views Asked by At

For the past 8+ months this has been crashing in my app. While I pride myself in being able to debug and fix anything, I have never once even been able to reproduce this crash. As this is code that runs A LOT and I am only seeing a random 2-3x crashes a week reported on this, my gut says it is a multi-threading timing issue with "something". I have implemented plenty of code changes in an attempt to fix it, but as of this week the issue remains.

Would love to just know precisely why the referenced line of code within AVFoundation would throw an internal exception or how I can go about finding that answer on my own. The following is the relevant portion of the stack trace. Sharing the code itself isn't realistic, so hoping this rings a bell for someone.

As background, this is for a music player app. This code is executed upon pressing the play button within the app (i.e., it runs correctly A LOT). Immediately prior to this, testing audioEngine.isRunning returns TRUE and the AVAudioPlayerNode is attached to the engine, etc. In other words, if this was something obvious, it would crash immediately.

Hardware Model:      iPhone16,2
AppVariant:          1:iPhone16,2:17
Code Type:           ARM-64 (Native)
Role:                Background

Date/Time:           2024-03-05 11:03:12.9509 +1000
Launch Time:         2024-03-02 18:01:24.2495 +1000
OS Version:          iPhone OS 17.3.1 (21D61)
Release Type:        User
Baseband Version:    1.40.01
Report Version:      104

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: SIGNAL 6 Abort trap: 6

Triggered by Thread:  0

Last Exception Backtrace:
0   CoreFoundation                  0x1b0a8a678 __exceptionPreprocess + 164 (NSException.m:249)
1   libobjc.A.dylib                 0x1a8d07c80 objc_exception_throw + 60 (objc-exception.mm:356)
2   CoreFoundation                  0x1b0b0f424 +[NSException raise:format:arguments:] + 96 (NSException.m:0)
3   AVFAudio                        0x1c9dd2d74 AVAE_RaiseException(NSString*, ...) + 52 (AVAEInternal.h:69)
4   AVFAudio                        0x1c9eaed5c AVAudioPlayerNodeImpl::StartImpl(AVAudioTime*) + 2524 (AVAudioPlayerNode.mm:660)
5   AVFAudio                        0x1c9dd31e4 AVAudioNodeImplBase::Start(AVAudioTime*) + 64 (AVAudioNodeImpl.h:176)
6   AVFAudio                        0x1c9eab440 -[AVAudioPlayerNode play] + 68 (AVAudioPlayerNode.mm:1138)

Have done everything short of asking StackOverflow sooner or re-writing the entire playback engine in an effort to fix this.

0

There are 0 best solutions below