Hi,
I have a question regarding error handling/reaction.
I received a couple of crash reports. It seems like some AudioNodes are deinit even when they are still used.
From the attached crash log I can see in line 14 that the AudioStreamingPlayer is deinit (BackendAudioPlayer.swift:44 in Amperfy).
The only place in Amperfy where I destroy the AudioStreaming.AudioPlayer is here: https://github.com/BLeeEZ/amperfy/blob/master/AmperfyKit/Player/BackendAudioPlayer.swift#L348
The new creation is only triggered in function handleError(error: Error) which reacts to AudioPlayer errors: https://github.com/BLeeEZ/amperfy/blob/master/AmperfyKit/Player/BackendAudioPlayer.swift#L293
I wasn't able to reproduce this crash on my side. Comments in the crash report state that it occurs during "normal" playback and suddenly the App crashes.
Here are my questions:
- Did you already encounter such a crash related to AudioNode deinits?
- What is a safe way to destroy an AudioStreaming.AudioPlayer?
- Is a call to
detachCustomAttachedNodes() strictly require before deinit or is there a recommended sequence to safely shutdown the player?
- What is the best way to react to any AudioPlayer error? In my case I don't want that any user notices an error. That's why I tear down the player and create a new one.
Thank you for your help in advance.
Thread 2 Crashed:
0 libobjc.A.dylib 0x00000001950823c8 getMethodNoSuper_nolock(objc_class*, objc_selector*) + 208 (objc-runtime-new.mm:7361)
1 libobjc.A.dylib 0x0000000195082d90 lookUpImpOrForward + 404 (objc-runtime-new.mm:7768)
2 libobjc.A.dylib 0x000000019507f4e4 _objc_msgSend_uncached + 68
3 AudioToolboxCore 0x00000001a47b5f28 -[AUAudioUnit deallocateRenderResources] + 52 (AUAudioUnit.mm:1079)
4 AudioToolboxCore 0x00000001a47ba78c -[AUAudioUnit dealloc] + 44 (AUAudioUnit.mm:593)
5 AudioToolboxCore 0x00000001a4810270 -[AUAudioUnitV2Bridge dealloc] + 56 (AUAudioUnitV2Bridge.mm:830)
6 AudioToolboxCore 0x00000001a4812de0 -[AUHALOutputUnit dealloc] + 160 (AUAudioUnitV2Bridge.mm:1856)
7 AVFAudio 0x00000001cf6ae9f8 AUInterfaceBaseV3::~AUInterfaceBaseV3() + 308 (AUInterface.mm:500)
8 AVFAudio 0x00000001cf684184 AUInterfaceV3::~AUInterfaceV3() + 16 (AUInterface.h:338)
9 AVFAudio 0x00000001cf683d90 AVAudioNodeImpl::~AVAudioNodeImpl() + 108 (AVAudioNode.mm:999)
10 AVFAudio 0x00000001cf5c44f0 AVAudioUnitImpl::~AVAudioUnitImpl() + 16 (AVAudioUnitImpl.h:23)
11 AVFAudio 0x00000001cf6809a8 -[AVAudioNode dealloc] + 68 (AVAudioNode.mm:70)
12 AmperfyKit 0x00000001056d39fc AudioPlayer.deinit + 408
13 AmperfyKit 0x000000010569bd50 AudioStreamingPlayer.deinit + 4 (/<compiler-generated>:0)
14 AmperfyKit 0x000000010569bd50 AudioStreamingPlayer.__deallocating_deinit + 12 (BackendAudioPlayer.swift:44)
15 libswiftCore.dylib 0x00000001951dfe60 _swift_release_dealloc + 56 (HeapObject.cpp:778)
16 libswiftCore.dylib 0x00000001951e0c04 bool swift::RefCounts<swift::SideTableRefCountBits>::doDecrementSlow<(swift::PerformDeinit)1>(swift::SideTableRefCountBits, unsigned int) + 168 (RefCount.h:1052)
17 AmperfyKit 0x00000001056ce480 RemoteAudioSource.processAudio(data:) + 376 (RemoteAudioSource.swift:325)
18 AmperfyKit 0x00000001056ce2c0 closure #1 in RemoteAudioSource.handleSuccessfulStreamEvent(response:) + 580 (RemoteAudioSource.swift:302)
19 AmperfyKit 0x000000010560d428 <deduplicated_symbol> + 28
20 Foundation 0x000000019575c354 <deduplicated_symbol> + 24
21 Foundation 0x000000019575bf44 -[NSBlockOperation main] + 96 (NSOperation.m:1565)
22 Foundation 0x000000019575c074 __NSOPERATION_IS_INVOKING_MAIN__ + 16 (NSOperation.m:2199)
23 Foundation 0x000000019575bb14 -[NSOperation start] + 640 (NSOperation.m:1407)
24 Foundation 0x000000019575bedc __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 16 (NSOperation.m:2230)
25 Foundation 0x000000019575b798 __NSOQSchedule_f + 164 (NSOperation.m:2241)
26 libdispatch.dylib 0x00000001d053c450 _dispatch_block_async_invoke2 + 148 (queue.c:598)
27 libdispatch.dylib 0x00000001d05467ec _dispatch_client_callout + 16 (client_callout.mm:85)
28 libdispatch.dylib 0x00000001d0535468 _dispatch_lane_serial_drain + 740 (queue.c:3991)
29 libdispatch.dylib 0x00000001d0535f44 _dispatch_lane_invoke + 388 (queue.c:4082)
30 libdispatch.dylib 0x00000001d05403ec _dispatch_root_queue_drain_deferred_wlh + 292 (queue.c:7265)
31 libdispatch.dylib 0x00000001d053fce4 _dispatch_workloop_worker_thread + 692 (queue.c:6859)
32 libsystem_pthread.dylib 0x00000001f41363b8 _pthread_wqthread + 292 (pthread.c:2696)
33 libsystem_pthread.dylib 0x00000001f41358c0 start_wqthread + 8
Hi,
I have a question regarding error handling/reaction.
I received a couple of crash reports. It seems like some AudioNodes are deinit even when they are still used.
From the attached crash log I can see in line 14 that the AudioStreamingPlayer is deinit (BackendAudioPlayer.swift:44 in Amperfy).
The only place in Amperfy where I destroy the AudioStreaming.AudioPlayer is here: https://github.com/BLeeEZ/amperfy/blob/master/AmperfyKit/Player/BackendAudioPlayer.swift#L348
The new creation is only triggered in function
handleError(error: Error)which reacts to AudioPlayer errors: https://github.com/BLeeEZ/amperfy/blob/master/AmperfyKit/Player/BackendAudioPlayer.swift#L293I wasn't able to reproduce this crash on my side. Comments in the crash report state that it occurs during "normal" playback and suddenly the App crashes.
Here are my questions:
detachCustomAttachedNodes()strictly require before deinit or is there a recommended sequence to safely shutdown the player?Thank you for your help in advance.