Fix black screen after restoring PiP when player window was closed on macOS

The expanded player window hidden for PiP is reused on restore, so its
MPVContainerNSView kept a stale weak reference to the shared render view
that the mini player preview had taken during PiP. On restore the mini
preview released the view as an orphan and the reused container skipped
re-attaching it because its guard only compared view identity.

- Skip re-attach in setPlayerView only when the view is still actually
  our subview, matching the iOS container's stolen-view handling
- Transfer the shared render view to another living container on unmount
  instead of orphaning it, since SwiftUI is not guaranteed to re-run
  updateNSView on a hidden window's content after restore
- Force a repaint when restoring the window hidden for PiP; forced draws
  requested while ordered out are dropped and the layer is pull-based
This commit is contained in:
Arkadiusz Fal
2026-06-08 22:55:31 +02:00
parent 0fa4df161b
commit 0d05daae9d
3 changed files with 71 additions and 6 deletions

View File

@@ -69,6 +69,11 @@ final class ExpandedPlayerWindowManager: NSObject {
existingWindow.alphaValue = 1
existingWindow.makeKeyAndOrderFront(nil)
}
// Any forced draw requested while the window was ordered out was
// dropped (no drawable); the layer is pull-based, so repaint now
// that the window is on screen otherwise a paused video stays
// black until the next MPV frame (never, while paused).
(appEnvironment.playerService.currentBackend as? MPVBackend)?.resumeRendering()
return
}