SwiftAudioEx
SwiftAudioEx copied to clipboard
Frequently crashed when using audio player event observer.
AppCenter Crash Log
$s12SwiftAudioEx20AVPlayerItemObserverC14startObserving4itemySo0dE0C_tFyyScMYccfU_ AVPlayerItemObserver.swift, line 76 SIGABRT: *** -[AVPlayerItem addOutput:] Cannot attach an output that is already attached or nil output
LAST EXCEPTION BACKTRACE
CoreFoundation
__exceptionPreprocess
libobjc.A.dylib
objc_exception_throw
AVFCore
-[AVPlayerItem(AVPlayerItemOutputs) addOutput:]
OralCraft
$s12SwiftAudioEx20AVPlayerItemObserverC14startObserving4itemySo0dE0C_tFyyScMYccfU_ AVPlayerItemObserver.swift:76
OralCraft
reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_unowned @convention(block) () -> () <compiler-generated>:0
libdispatch.dylib
_dispatch_client_callout
libdispatch.dylib
_dispatch_continuation_pop
libdispatch.dylib
_dispatch_source_invoke
libdispatch.dylib
_dispatch_main_queue_drain
libdispatch.dylib
_dispatch_main_queue_callback_4CF
CoreFoundation
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
CoreFoundation
__CFRunLoopRun
CoreFoundation
CFRunLoopRunSpecific
GraphicsServices
GSEventRunModal
UIKitCore
-[UIApplication _run]
UIKitCore
UIApplicationMain
OralCraft
main main.swift:11
0x00000001e6290dec
Describe the bug Use Cases
_player.load(item: audioItem, playWhenReady: false)
_player.timeEventFrequency = .custom(time: CMTime(value: 1, timescale: 100))
_player.event.secondElapse.addListener(self) { [weak self] data in
guard let self else { return }
if self._player.currentTime > playbackTime.end {
DispatchQueue.main.async {
self._player.stop()
self._player.event.secondElapse.removeListener(self)
}
}
}
_player.rate = 1.0
_player.playWhenReady = true
activateSessionIfNeeded()
Smartphone:
- Device: [iPhone16,2, iPhone 11 Pro Max, iPhone13,4]
- OS: [iOS 16.0, 16.6.1, 17.1.1]
- Version [0.15.3]
I just tried your example code and was unable to reproduce this with the iOS sample app. You might try a more recent commit; I notice your line numbers are different than what's in the code.