diff mbox series

[meta-oe,1/3] mpv: fix a file descriptor leak in the render API

Message ID 20261005011956.1224267-1-f_l_k@t-online.de
State New
Headers show
Series [meta-oe,1/3] mpv: fix a file descriptor leak in the render API | expand

Commit Message

Markus Volk Oct. 5, 2026, 1:19 a.m. UTC
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>
---
 ...equire-swap_buffers-param-for-FenceS.patch | 35 +++++++++++++++++++
 .../recipes-multimedia/mplayer/mpv_0.41.0.bb  |  5 ++-
 2 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-multimedia/mplayer/mpv/0001-opengl-context-require-swap_buffers-param-for-FenceS.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-multimedia/mplayer/mpv/0001-opengl-context-require-swap_buffers-param-for-FenceS.patch b/meta-oe/recipes-multimedia/mplayer/mpv/0001-opengl-context-require-swap_buffers-param-for-FenceS.patch
new file mode 100644
index 0000000000..70ba81b34c
--- /dev/null
+++ b/meta-oe/recipes-multimedia/mplayer/mpv/0001-opengl-context-require-swap_buffers-param-for-FenceS.patch
@@ -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);
diff --git a/meta-oe/recipes-multimedia/mplayer/mpv_0.41.0.bb b/meta-oe/recipes-multimedia/mplayer/mpv_0.41.0.bb
index c8a0222ebf..7178182c29 100644
--- a/meta-oe/recipes-multimedia/mplayer/mpv_0.41.0.bb
+++ b/meta-oe/recipes-multimedia/mplayer/mpv_0.41.0.bb
@@ -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