SRGSSR / pillarbox-apple

A next-generation reactive media playback ecosystem for Apple platforms.
https://testflight.apple.com/join/TS6ngLqf
MIT License
51 stars 7 forks source link

Playback is paused when a monoscopic view is destroyed #703

Open defagos opened 9 months ago

defagos commented 9 months ago

Description of the problem

As already known from the SRG Media Player era, playback is paused when the a monoscopic view associated with a player is destroyed, because of the SKVideoNode being destroyed.

Relevant stack trace or log output

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 4.1
  * frame #0: 0x00000001047308dc Pillarbox-demo`closure #1 in Player.init(rate=0) at Player.swift:151:27
    frame #1: 0x00000001b187fa98 Combine`Combine.Subscribers.Sink.receive(τ_0_0) -> Combine.Subscribers.Demand + 88
    frame #2: 0x00000001b18800b8 Combine`protocol witness for Combine.Subscriber.receive(τ_0_0.Input) -> Combine.Subscribers.Demand in conformance Combine.Subscribers.Sink<τ_0_0, τ_0_1> : Combine.Subscriber in Combine + 20
    frame #3: 0x000000018079e45c Foundation`__C.NSObject.KVOSubscription.changes() -> () + 628
    frame #4: 0x000000018079e1cc Foundation`closure #1 @Sendable (τ_0_0, Foundation.NSKeyValueObservedChange<τ_0_1>) -> () in __C.NSObject.KVOSubscription.init(τ_0_0, Swift.KeyPath<τ_0_0, τ_0_1>, __C.NSKeyValueObservingOptions, τ_0_2) -> __C.NSObject.KVOSubscription<τ_0_0, τ_0_1, τ_0_2> + 32
    frame #5: 0x00000001807ff18c Foundation`closure #1 @Sendable (__C.NSObject, Foundation.NSKeyValueObservedChange<Any>) -> () in Foundation._KeyValueCodingAndObserving.observe<τ_0_0>(_: Swift.KeyPath<τ_0_0, τ_1_0>, options: __C.NSKeyValueObservingOptions, changeHandler: (τ_0_0, Foundation.NSKeyValueObservedChange<τ_1_0>) -> ()) -> Foundation.NSKeyValueObservation + 304
    frame #6: 0x00000001808023ec Foundation`function signature specialization <Arg[0] = Dead, Arg[3] = Dead> of Foundation.NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath: Swift.Optional<Swift.String>, of: Swift.Optional<Any>, change: Swift.Optional<Swift.Dictionary<__C.NSString, Any>>, context: Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () + 1040
    frame #7: 0x00000001807fec88 Foundation`@objc Foundation.NSKeyValueObservation.Helper._swizzle_me_observeValue(forKeyPath: Swift.Optional<Swift.String>, of: Swift.Optional<Any>, change: Swift.Optional<Swift.Dictionary<__C.NSString, Any>>, context: Swift.Optional<Swift.UnsafeMutableRawPointer>) -> () + 156
    frame #8: 0x0000000180d60578 Foundation`NSKeyValueNotifyObserver + 248
    frame #9: 0x0000000180d6352c Foundation`NSKeyValueDidChange.llvm.15926355064634155016 + 352
    frame #10: 0x0000000180d5fb3c Foundation`NSKeyValueDidChangeWithPerThreadPendingNotifications.llvm.15926355064634155016 + 144
    frame #11: 0x00000001c772cb50 AVFCore`-[AVPlayer _setRate:rateChangeReason:figPlayerSetRateHandler:] + 312
    frame #12: 0x00000001c772d0e0 AVFCore`-[AVPlayer _setRate:withVolumeRampDuration:playImmediately:rateChangeReason:affectsCoordinatedPlayback:] + 140
    frame #13: 0x00000001c772d4f8 AVFCore`-[AVPlayer setRate:] + 56
    frame #14: 0x00000001a27cf538 SpriteKit`SKCVideoNode::~SKCVideoNode() + 44
    frame #15: 0x00000001a27cf618 SpriteKit`SKCVideoNode::~SKCVideoNode() + 12
    frame #16: 0x00000001a279b3cc SpriteKit`-[SKNode dealloc] + 48
    frame #17: 0x00000001a27b8470 SpriteKit`-[SKVideoNode dealloc] + 156
    frame #18: 0x0000000180378028 CoreFoundation`-[__NSArrayM removeAllObjects] + 212
    frame #19: 0x00000001a279b3dc SpriteKit`-[SKNode dealloc] + 64
    frame #20: 0x00000001a2769ea4 SpriteKit`-[SKScene dealloc] + 260
    frame #21: 0x000000019c070178 SceneKit`-[SCNSpriteKitSource dealloc] + 36
    frame #22: 0x000000019c0ef804 SceneKit`_C3DImageProxyCFFinalize + 96
    frame #23: 0x00000001803f3b98 CoreFoundation`_CFRelease + 280
    frame #24: 0x000000019c107ac0 SceneKit`_C3DEffectSlotCFFinalize + 40
    frame #25: 0x00000001803f3b98 CoreFoundation`_CFRelease + 280
    frame #26: 0x000000019c10430c SceneKit`_C3DEffectCommonProfileCFFinalize + 288
    frame #27: 0x00000001803f3b98 CoreFoundation`_CFRelease + 280
    frame #28: 0x000000019c15051c SceneKit`_C3DMaterialCFFinalize + 60
    frame #29: 0x00000001803f3b98 CoreFoundation`_CFRelease + 280
    frame #30: 0x0000000180379b7c CoreFoundation`__RELEASE_OBJECTS_IN_THE_ARRAY__ + 112
    frame #31: 0x0000000180379abc CoreFoundation`-[__NSArrayM dealloc] + 144
    frame #32: 0x000000019c0335ac SceneKit`_C3DGeometryCFFinalize + 120
    frame #33: 0x00000001803f3b98 CoreFoundation`_CFRelease + 280
    frame #34: 0x000000019c145540 SceneKit`_C3DNodeCFFinalize + 228
    frame #35: 0x00000001803f3b98 CoreFoundation`_CFRelease + 280
    frame #36: 0x000000019c2664fc SceneKit`C3DTransactionFlush + 1920
    frame #37: 0x00000001803f0ec4 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
    frame #38: 0x00000001803eb8c8 CoreFoundation`__CFRunLoopDoObservers + 528
    frame #39: 0x00000001803ebd80 CoreFoundation`__CFRunLoopRun + 968
    frame #40: 0x00000001803eb5a4 CoreFoundation`CFRunLoopRunSpecific + 572
    frame #41: 0x000000018e9fbae4 GraphicsServices`GSEventRunModal + 160
    frame #42: 0x00000001852f02e4 UIKitCore`-[UIApplication _run] + 868
    frame #43: 0x00000001852f3f5c UIKitCore`UIApplicationMain + 124
    frame #44: 0x00000001c51fc1b0 SwiftUI`___lldb_unnamed_symbol205407 + 172
    frame #45: 0x00000001c51fc050 SwiftUI`___lldb_unnamed_symbol205405 + 140
    frame #46: 0x00000001c4f02fa4 SwiftUI`static SwiftUI.App.main() -> () + 80
    frame #47: 0x0000000104691eec Pillarbox-demo`static DemoApp.$main(self=Pillarbox_demo.DemoApp) at <compiler-generated>:0
    frame #48: 0x00000001046920d8 Pillarbox-demo`main at DemoApp.swift:10:8
    frame #49: 0x0000000104f75544 dyld_sim`start_sim + 20
    frame #50: 0x00000001051d60e0 dyld`start + 2360

Reproducibility

Always

Steps to reproduce

  1. Open the Pillarbox demo after #702 has been merged.
  2. Open the Multi-instance with mixed content example from the Showcase tab.
  3. Swap the players. Playback is paused.

The trace above was obtained with a breakpoint detecting rate changes to 0.

Library version

0.8.0

Operating system

iOS 17.2

Code sample

No response

Is there an existing issue for this?

defagos commented 9 months ago

For the moment has been listed in the known issues but it is likely a fix is possible