Skip to content

VideoPlayerViewController: Fix frozen video on external display after backgrounding - #464

Open
pavellunev wants to merge 1 commit into
videolan:masterfrom
pavellunev:fix-external-display-foreground-freeze
Open

pavellunev wants to merge 1 commit into
videolan:masterfrom
pavellunev:fix-external-display-foreground-freeze

Conversation

@pavellunev

Copy link
Copy Markdown

Summary

Playing video on a wired external display (USB-C/HDMI) freezes after the app
is sent to the background and brought back to the foreground: the picture
stays on the last frame on the external monitor while audio and the timeline
keep advancing. Only physically reconnecting the display restores the picture.

Cause

The video output view that hosts the vout render surface lives inside the
external UIWindow. While the app is backgrounded, that surface is
invalidated (GPU rendering is not allowed in the background). On foreground
nothing re-attaches or recreates it, so the external display keeps showing
the stale frame. Reconnecting the cable works only because iOS recreates the
external scene/window, which re-runs the attach path.

Fix

In playerControllerApplicationBecameActive, when the app becomes active
again while playing on an external screen (and not casting to a renderer,
with an external window present), toggle the video output off and back on
(videoOutputView = nil then the view again). This removes the output view
from the external window and re-inserts it, forcing the vout surface to be
recreated.

The new branch is guarded so it is only entered for a wired external display:
isPlayingOnExternalScreen() together with renderer == nil excludes
Chromecast, and externalWindow != nil excludes the local-screen case, which
keeps following the existing code path unchanged.

Testing

Verified on a physical device with a wired external monitor: play video →
background → return to foreground → the picture resumes in sync with audio
without reconnecting the display.

… backgrounding

When playing on a wired external screen, sending the app to the background
and returning to the foreground left the picture frozen on the external
display while audio and the timeline kept advancing. The video output layer
hosted in the external window has its render surface invalidated while
backgrounded, and nothing on foreground forces it to be recreated, so only
physically reconnecting the display recovered playback.

When the app becomes active again while playing on an external screen (and
not casting to a renderer), re-attach the video output by toggling it off
and back on. This tears the output view out of the external window and
re-inserts it, forcing the vout surface to be recreated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant