Fix macOS black video after re-parenting the shared player view

The player video surface is a single shared MPVOGLView that is re-parented
between the mini-bar container (main window) and the expanded-player sheet
(a separate sheet window). When presenting the sheet, the new container
attaches the shared view before the old mini-bar container tears down, so
the old container's viewWillMove(toSuperview: nil) was ripping the shared
view out of its new home via removeFromSuperview() — leaving it with no
window and a black surface. Symmetric, so it also blanked the mini-bar
preview after collapsing.

Only detach the shared view if it still belongs to the container
(superview === self). Also force a repaint on window reattach so a paused
frame redraws, and extend the onAppear resumeRendering to macOS.
This commit is contained in:
Arkadiusz Fal
2026-05-25 19:46:35 +02:00
parent fe4e3c531a
commit 5f49f2d022
3 changed files with 23 additions and 5 deletions

View File

@@ -143,11 +143,12 @@ struct MPVVideoView: View {
applies: appliesAspectRatio
))
.onAppear {
#if os(iOS)
#if os(iOS) || os(macOS)
// Resume the MPV display link when the expanded video view appears.
// MiniPlayerView pauses rendering when its video preview hides during expand;
// PlayerService.playerSheetDidAppear is gated behind background playback, so it
// can't be relied on to resume.
// can't be relied on to resume. On macOS this also recovers the sheet re-open
// black screen when the shared render view reappears without a window re-parent.
backend.resumeRendering()
#endif
// Start debug updates if overlay is already visible when view appears