Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frequently crashed when using audio player event observer. #73

Open
Jinya opened this issue Nov 29, 2023 · 1 comment
Open

Frequently crashed when using audio player event observer. #73

Jinya opened this issue Nov 29, 2023 · 1 comment

Comments

@Jinya
Copy link

Jinya commented Nov 29, 2023

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]
@bsneed
Copy link
Contributor

bsneed commented Apr 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants