pillarbox-apple icon indicating copy to clipboard operation
pillarbox-apple copied to clipboard

Minor visual glitch in the multi-instance demo

Open defagos opened this issue 1 year ago • 1 comments

Description of the problem

When toggling the active view in the MultiView demo the previous view can briefly be seen:

https://github.com/SRGSSR/pillarbox-apple/assets/170201/7f29d7ff-0278-449a-997e-39768a35298a

Relevant stack trace or log output

No response

Reproducibility

Always

Steps to reproduce

  1. Open the Multi-instance demo available from the Showcase tab.
  2. Tap on each view in sequence and observe the video boxes.

Library version

0.8.0

Operating system

iOS 17.2

Code sample

If you update the PiP supporting video view as follows:

struct PictureInPictureSupportingVideoView: UIViewRepresentable {
    let player: Player
    let gravity: AVLayerVideoGravity

    static func dismantleUIView(_ uiView: VideoLayerView, coordinator: Void) {
        PictureInPicture.shared.custom.relinquish(for: uiView.playerLayer)
    }

    func makeUIView(context: Context) -> VideoLayerView {
        let view = VideoLayerView(from: PictureInPicture.shared.custom.playerLayer)
        PictureInPicture.shared.custom.acquire(for: view.playerLayer)
        return view
    }

    func updateUIView(_ uiView: VideoLayerView, context: Context) {
        DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
            uiView.player = player.queuePlayer
            uiView.playerLayer.videoGravity = gravity
        }
    }
}

The delay lets you see the video view update sequence. The glitch results from the fact we reuse a previous layer. There is likely a way to mitigate it.

Is there an existing issue for this?

  • [X] I have searched existing issues and found no similar bug report.

defagos avatar Dec 21 '23 16:12 defagos

Slight flickering also visible in the opt-in demo when toggling the PiP option, once #702 has been merged.

defagos avatar Dec 21 '23 20:12 defagos