SRGSSR / srgletterbox-apple

The official SRG SSR media playback experience
https://srgssr.github.io/marketing/letterbox/
MIT License
14 stars 7 forks source link

PiP should not be started when no Letterbox view is attached #256

Open defagos opened 2 years ago

defagos commented 2 years ago

If no Letterbox view is attached, PiP might still be automatically enabled. This should not be the case.

Issue type

Incorrect behavior

Environment information

Reproducibility

Always reproducible

Steps to reproduce

  1. Play the SWI VOD example.
  2. Use the toggle button to detach the Letterbox view from its controller.
  3. Send the app to the background.

On iOS 15 PiP is automatically enabled. On 14.8 the behavior is left in an inconsistent state.

defagos commented 2 years ago

Can be reproduced in SRG Media Player controller demo:

  1. Edit the code to have a button which removes the controller view from its parent view in the advanced demo.
  2. Start playback.
  3. Tap on the button.
  4. Send the app to the background.

Note that the view has to be displayed once at least. If the view is removed before playback (or not installed at all), the issue does not appear.

defagos commented 2 years ago

It is obvious that this behavior is related to the fact that a PiP controller is bound to the player layer, even if this layer is not installed in the hierarchy.

We cannot destroy the PiP controller to avoid this behavior when the layer is not installed, as this would break PiP as soon as the player view is removed from the hierarchy (e.g. player screen dismissal when PiP is entered). For this reason I think there is no way to solve this issue.

I'll check the behavior on iOS < 14 to see if this is an iOS regression which appeared with iOS 14, but I doubt we can do more than reporting this issue to Apple.

defagos commented 2 years ago

Tested with iOS 13.7, the behavior is correct: If the video layer is attached, playback is paused when moving to the background with the LB view dissociated from the player, and no PiP overlay appears.

It seems to me this is really an iOS 14 regression which we cannot do much with. We should keep track of potential improvements made in later iOS releases and, if this is really an issue, open a dedicated Apple bug report.