mpv: fix a file descriptor leak in the render API

With the OpenGL render API (vo_libmpv) every frame left a fence behind
that nothing cleaned up. On v3d each one holds a sync file, so after about
a minute of video the process ran into the open file limit and the
picture stopped ("MESA: error: Export failed"). Backport the upstream
fix.

AI-Generated: Uses Claude Code (Claude Fable 5.1)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Markus Volk authored and Khem Raj committed 2026-10-09 10:01:37 -07:00
1 parent 53fd588e94
commit 2826f6233d
2 files changed
+39 -1

No files matched your search

@@ -0,0 +1,35 @@
From f74adc4243bd9e1a8ee96d187c939e6232510650 Mon Sep 17 00:00:00 2001
From: Dudemanguy <random342@airmail.cc>
Date: Thu, 22 Jan 2026 11:12:22 -0600
Subject: [PATCH] opengl/context: require swap_buffers param for FenceSync
Commits 8854c742711705be1fcfcc6a5875960a3e2593dc and
5ae0e0ff9a6974453c1aba41ddc8442d12ac9264 eliminated the external
swapchain API that the render backend (vo_libmpv) was previously using.
However, it was missed that this was being used to skip the
gl->FenceSync calls and that logic change was not properly accounted
for. This meant that vo_libmpv would leak fences since
ra_gl_ctx_swap_buffers is never called to clean them up.
Fix this by making sure the ra_ctx_params have swap_buffers defined
before calling gl->FenceSync. All platforms are required to implement
this anyway with the exception of vo_libmpv since it's a funny special
case. Fixes #17217.
Upstream-Status: Backport [https://github.com/mpv-player/mpv/commit/f74adc4243bd9e1a8ee96d187c939e6232510650]
---
video/out/opengl/context.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/video/out/opengl/context.c b/video/out/opengl/context.c
index 86e8d5daac8b4..86e5c797d670a 100644
--- a/video/out/opengl/context.c
+++ b/video/out/opengl/context.c
@@ -232,7 +232,7 @@ bool ra_gl_ctx_submit_frame(struct ra_swapchain *sw, const struct vo_frame *fram
if (p->opts->use_glfinish)
gl->Finish();
- if (gl->FenceSync) {
+ if (gl->FenceSync && p->params.swap_buffers) {
GLsync fence = gl->FenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
if (fence)
MP_TARRAY_APPEND(p, p->vsync_fences, p->num_vsync_fences, fence);
@@ -23,7 +23,10 @@ LIC_FILES_CHKSUM = "file://LICENSE.GPL;md5=570a9b3749dd0463a1778803b12a6dce"
LICENSE_FLAGS = "commercial"
SRCREV = "41f6a645068483470267271e1d09966ca3b9f413"
SRC_URI = "git://github.com/mpv-player/mpv;name=mpv;branch=release/${@oe.utils.trim_version('${PV}', 2)};protocol=https;tag=v${PV}"
SRC_URI = " \
git://github.com/mpv-player/mpv;name=mpv;branch=release/${@oe.utils.trim_version('${PV}', 2)};protocol=https;tag=v${PV} \
file://0001-opengl-context-require-swap_buffers-param-for-FenceS.patch \
"
inherit meson pkgconfig mime-xdg