From 493df28b8df289de18025762aaf82410af77b9bf Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sun, 18 Jan 2026 22:11:35 +0100 Subject: [PATCH] fix(player): resolve tvOS freeze on player exit by reordering mpv options --- modules/mpv-player/ios/MPVLayerRenderer.swift | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/mpv-player/ios/MPVLayerRenderer.swift b/modules/mpv-player/ios/MPVLayerRenderer.swift index 785fd9e3..35b112eb 100644 --- a/modules/mpv-player/ios/MPVLayerRenderer.swift +++ b/modules/mpv-player/ios/MPVLayerRenderer.swift @@ -176,16 +176,17 @@ final class MPVLayerRenderer { // Use AVFoundation video output - required for PiP support checkError(mpv_set_option_string(handle, "vo", "avfoundation")) + // Enable composite OSD mode - renders subtitles directly onto video frames using GPU + // This is better for PiP as subtitles are baked into the video + // NOTE: Must be set BEFORE the #if targetEnvironment check or tvOS will freeze on player exit + checkError(mpv_set_option_string(handle, "avfoundation-composite-osd", "yes")) + // Hardware decoding with VideoToolbox // On simulator, use software decoding since VideoToolbox is not available // On device, use VideoToolbox with software fallback enabled #if targetEnvironment(simulator) checkError(mpv_set_option_string(handle, "hwdec", "no")) #else - // Only enable composite OSD mode on real device (OSD is not supported in simulator). - // This renders subtitles directly onto video frames using the GPU, which is better for PiP since subtitles are baked into the video. - checkError(mpv_set_option_string(handle, "avfoundation-composite-osd", "yes")) - checkError(mpv_set_option_string(handle, "hwdec", "videotoolbox")) #endif checkError(mpv_set_option_string(handle, "hwdec-codecs", "all"))