Closed defagos closed 5 months ago
I already opened a branch and updated the demo according to the above report. I have no clue for a solution yet.
I think I found a strategy:
enabledForInAppPictureInPictureWithCleanup(perform:)
into methods on VideoView
and SystemVideoView
. This way we cannot have a dangling modifier without associated view. This should fix the reference counting issue reliably.PictureInPicture
umbrella object in the process (remains to be investigated).If this strategy works there is also probably an opportunity to change the API so that the basic and in-app PiP are two different modifiers (or parameters to video views), rather than having a Boolean and an associated closure on a modifier (leading to combinations that do not make sense, e.g. PiP not supported but cleanup block assigned).
It might even be possible to make our implementation simpler.
All use cases must pass as before, e.g.:
Not sure the above strategy works, as it binds the lifetime of the extended PiP to the lifetime of the video view, thus extended nothing.
Working on another strategy. Just a side note: It seems pauses during PiP restoration might occur when the item is switched before the PiP restoration. The item should really be updated after PiP will stop delegate method has been called.
The very same issue affects our ability to implement advanced PiP in the MultiView
example.
The issue has been fixed in PR #702. The demo has also been improved to test advanced PiP in the context of multiple players and multiple views.
Description of the problem
The current reference counting strategy implemented for PiP sadly has a flaw. We did not notice it because of our demo implementation but in general it will fail if the player view enabled for PiP is initially displayed without
VideoView
actually in the hierarchy.In this case the reference counter is not increased initially on view entry (since
playerLayer
isnil
) but will be on exit, leading to early PiP controller deallocation.Relevant stack trace or log output
No response
Reproducibility
Always
Steps to reproduce
Edit the
PlaybackView
code so that noVideoView
is displayed when the stream type is unknown (always the case initially in our demo):Run the demo, open an example with the custom player and enable PiP with the dedicated button. PiP is incorrectly exited.
Library version
0.8.0
Operating system
iOS 17
Code sample
No response
Is there an existing issue for this?