Hand off render view to mini capsule immediately on player collapse

The capsule's claim on the shared render view is declined during the
player window's fade-out (the window is still visible, so the steal
guard refuses), and nothing retried after orderOut - the capsule stayed
black until the render watchdog recovered the view ~10 seconds later.

Call recoverSharedPlayerViewIfNeeded() in hide()'s cleanup right after
ordering the window out, so the view moves to the capsule as soon as
the collapse finishes. The PiP path is untouched - there the view must
stay in the hidden window.
This commit is contained in:
Arkadiusz Fal
2026-06-22 20:19:25 +02:00
parent bf00c48e6c
commit 945804c109

View File

@@ -201,7 +201,8 @@ final class ExpandedPlayerWindowManager: NSObject {
// Check if PiP is active - if so, just hide the window without destroying content
// The AVSampleBufferDisplayLayer needs to stay alive while PiP is active
let isPiPActive = (appEnvironment?.playerService.currentBackend as? MPVBackend)?.isPiPActive ?? false
let mpvBackend = appEnvironment?.playerService.currentBackend as? MPVBackend
let isPiPActive = mpvBackend?.isPiPActive ?? false
LoggingService.shared.debug("ExpandedPlayerWindowManager: hide() called, isPiPActive=\(isPiPActive)", category: .player)
@@ -240,6 +241,14 @@ final class ExpandedPlayerWindowManager: NSObject {
// Don't set contentViewController to nil or call close() - just order out
// This lets SwiftUI views deallocate naturally rather than being forcibly torn down
window.orderOut(nil)
// The mini capsule's claim on the shared render view was
// declined while this window was still visible during the
// fade-out, and nothing retries after orderOut - hand the
// view over now instead of leaving the capsule black until
// the render watchdog recovers it.
if MPVContainerNSView.recoverSharedPlayerViewIfNeeded() {
mpvBackend?.resumeRendering()
}
completion?()
}
}