Fix macOS player window black video when mini capsule steals render view

Closing the player window via its close button left isPlayerCollapsing
stuck true (windowShouldClose has no animation completion to clear it),
so the mini capsule preview kept mounting its render container and
grabbed the shared render view on the next expand - the video rendered
into the 44x26 thumbnail while the player window stayed black.

- Clear isPlayerCollapsing on the next runloop in windowShouldClose
- Give containers in the tracked player window priority to claim the
  shared view (even from a visible owner), and refuse steals from the
  visible player window by outside containers
- Prefer the largest container in the player window during recovery so
  thumbnail-sized surfaces are never picked
- Add a watchdog misplaced-view check in MPVBackend that re-attaches
  the render view when it lives outside the visible player window
- Include container bounds and tracked-window flag in attach/decline
  logs
This commit is contained in:
Arkadiusz Fal
2026-06-22 19:55:32 +02:00
parent b82241564d
commit bf00c48e6c
3 changed files with 106 additions and 24 deletions

View File

@@ -2096,6 +2096,23 @@ extension MPVBackend: MPVClientDelegate {
previousVoDrops = voDrops ?? previousVoDrops
}
// Misplaced-view check: the player window is on screen but the
// shared render view lives in a different window (e.g. the mini
// capsule preview grabbed it during an expand race). Draws look
// healthy, yet the player window shows black.
if !self.isPiPActive,
let playerWindow = ExpandedPlayerWindowManager.shared.currentPlayerWindow,
playerWindow.isVisible,
let view = self._playerView, view.window !== playerWindow {
LoggingService.shared.warning(
"MPV render watchdog: player view outside visible player window (attach: \(view.attachmentDescription)) - re-attaching",
category: .mpv
)
if MPVContainerNSView.recoverSharedPlayerViewIfNeeded() {
self.resumeRendering()
}
}
#endif
// Gate on the verbose setting each tick (not at task start) so