From 76e5220c95fb7e12039a010b296a0d49ebeb7bed Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 4 Jun 2026 21:24:43 +0200 Subject: [PATCH] Fix no video on iOS/tvOS devices after GL two-thread hardening 1d9c5e3b removed the main-thread EAGLContext bind from setupAsync so the context is never left current on two threads. But libmpv's mpv_render_context_create requires a current GL context on the calling thread (it probes glGetString(GL_VERSION)), so render context creation failed with MPV_ERROR_UNSUPPORTED (-18) and every video played with no --vo ("No render context set") on real iOS/tvOS devices. Bind the context around the createRenderContext call and unbind right after. The bind is scoped to setup, before the display link starts and before any frame is rendered, so the never-left-current invariant that protects the A10X fence fix (#947/#949) still holds. Verified on Apple TV 4K (3rd gen): createRenderContext succeeds and video frames render. Claude-Session: https://claude.ai/code/session_01UEXP5f6F4S1zLdY8fdVuLJ --- Yattee/Services/Player/MPV/MPVRenderView.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Yattee/Services/Player/MPV/MPVRenderView.swift b/Yattee/Services/Player/MPV/MPVRenderView.swift index 08b2c6f8..033d2149 100644 --- a/Yattee/Services/Player/MPV/MPVRenderView.swift +++ b/Yattee/Services/Player/MPV/MPVRenderView.swift @@ -521,8 +521,13 @@ final class MPVRenderView: UIView { } } - // Create MPV render context with our getProcAddress function + // Create MPV render context with our getProcAddress function. + // mpv_render_context_create probes GL (glGetString) on the calling thread — + // the EAGL context must be current here. Unbind after so it isn't left + // current on main (performRender binds it on the render queue per frame). + EAGLContext.setCurrent(context) let success = client.createRenderContext(getProcAddress: getProcAddress) + EAGLContext.setCurrent(nil) if !success { MPVLogging.warn("setupAsync: failed to create MPV render context") throw MPVRenderError.renderContextFailed(-1)