This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 369eaab2d2e35379bb88fb799e1e968c3f98104b
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 10:46:46 2026 -0600
evas:gl_drm: keep one EGL context across resizes
evas_outbuf_reconfigure() ran the whole EGL setup again on every
resize, when only the window surface depends on the size. Each resize
called eglInitialize() again, created a new EGLContext without
destroying the one it replaced, and took one more reference on the
shared Evas GL common context through
evas_gl_common_context_new().
The extra reference is the visible damage: evas_outbuf_free() only
terminates the EGL display and forgets the static share context when it
drops the last reference, so after any resize it never gets there. The
display, its file descriptor and the first context stay alive for the
life of the process, and the next canvas shares its context with a
stale one.
Create the window surface again on resize and leave the display, the
config and the contexts alone. The Evas GL context is made current on
the new surface and resized as before, and a failed eglMakeCurrent()
still returns before either.
One behaviour changes beyond the leak: after a resize, the path where
eng_output_update() frees the outbuf and creates another (depth or
alpha changed) now really terminates EGL and frees the common context,
as it always did for a canvas that was never resized.
The test draws with no DRM device, which the previous change allows,
and checks that a canvas resized several times leaves no descriptor of
the render node open once freed. It proves the fix only on drivers whose
EGL duplicates the DRM descriptor, which Mesa does; elsewhere it passes
either way.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
src/modules/evas/engines/gl_drm/evas_outbuf.c | 62 ++++++++++++++++++---------
src/tests/evas/evas_test_gl_drm.c | 38 ++++++++++++++++
2 files changed, 79 insertions(+), 21 deletions(-)
diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c b/src/modules/evas/engines/gl_drm/evas_outbuf.c
index 525f4f9bc5..6623d6e674 100644
--- a/src/modules/evas/engines/gl_drm/evas_outbuf.c
+++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c
@@ -294,6 +294,32 @@ _evas_outbuf_legacy_egl_display_get(struct gbm_device *gbm)
return disp;
}
+static Eina_Bool
+_evas_outbuf_egl_surface_create(Outbuf *ob)
+{
+ if (ob->egl.surface != EGL_NO_SURFACE)
+ eglDestroySurface(ob->egl.disp, ob->egl.surface);
+ ob->egl.surface = EGL_NO_SURFACE;
+#ifdef EGL_MESA_platform_gbm
+ if (dlsym_eglCreatePlatformWindowSurfaceEXT)
+ ob->egl.surface =
+ dlsym_eglCreatePlatformWindowSurfaceEXT(ob->egl.disp, ob->egl.config,
+ ob->surface, NULL);
+#endif
+ if (ob->egl.surface == EGL_NO_SURFACE)
+ ob->egl.surface = eglCreateWindowSurface(ob->egl.disp, ob->egl.config,
+ (EGLNativeWindowType)ob->surface,
+ NULL);
+ if (ob->egl.surface == EGL_NO_SURFACE)
+ {
+ ERR("eglCreateWindowSurface() fail for %p. code=%#x",
+ ob->surface, eglGetError());
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
+}
+
static Eina_Bool
_evas_outbuf_egl_setup(Outbuf *ob)
{
@@ -392,7 +418,7 @@ _evas_outbuf_egl_setup(Outbuf *ob)
}
/* cleared so the check below sees a failed search rather than a config
- * left over from an earlier setup (this runs again on resize) */
+ * left over from an earlier setup */
ob->egl.config = NULL;
for (; i < ncfg; ++i)
{
@@ -423,25 +449,7 @@ _evas_outbuf_egl_setup(Outbuf *ob)
goto err;
}
- if (ob->egl.surface != EGL_NO_SURFACE)
- eglDestroySurface(ob->egl.disp, ob->egl.surface);
- ob->egl.surface = EGL_NO_SURFACE;
-#ifdef EGL_MESA_platform_gbm
- if (dlsym_eglCreatePlatformWindowSurfaceEXT)
- ob->egl.surface =
- dlsym_eglCreatePlatformWindowSurfaceEXT(ob->egl.disp, ob->egl.config,
- ob->surface, NULL);
-#endif
- if (ob->egl.surface == EGL_NO_SURFACE)
- ob->egl.surface = eglCreateWindowSurface(ob->egl.disp, ob->egl.config,
- (EGLNativeWindowType)ob->surface,
- NULL);
- if (ob->egl.surface == EGL_NO_SURFACE)
- {
- ERR("eglCreateWindowSurface() fail for %p. code=%#x",
- ob->surface, eglGetError());
- goto err;
- }
+ if (!_evas_outbuf_egl_surface_create(ob)) goto err;
ob->egl.context =
eglCreateContext(ob->egl.disp, ob->egl.config, context, ctx_attr);
@@ -708,7 +716,19 @@ evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth)
else if ((ob->rotation == 90) || (ob->rotation == 270))
_evas_outbuf_gbm_surface_create(ob, h, w);
- _evas_outbuf_egl_setup(ob);
+ if (!_evas_outbuf_egl_surface_create(ob)) return;
+
+ if (eglMakeCurrent(ob->egl.disp, ob->egl.surface, ob->egl.surface,
+ ob->egl.context) == EGL_FALSE)
+ {
+ ERR("eglMakeCurrent() failed!");
+ return;
+ }
+
+ evas_outbuf_use(ob);
+ glsym_evas_gl_common_context_resize(ob->gl_context,
+ ob->w, ob->h, ob->rotation);
+ ob->surf = EINA_TRUE;
}
Render_Output_Swap_Mode
diff --git a/src/tests/evas/evas_test_gl_drm.c b/src/tests/evas/evas_test_gl_drm.c
index 0ef569d036..f47d1267ce 100644
--- a/src/tests/evas/evas_test_gl_drm.c
+++ b/src/tests/evas/evas_test_gl_drm.c
@@ -116,6 +116,12 @@ _fd_count_on(const char *prefix)
return count;
}
+static int
+_render_nodes_fd_count(void)
+{
+ return _fd_count_on("/dev/dri/renderD");
+}
+
/* The engine reports what went wrong in a frame it could not deliver, so
* a test that expects no trouble counts what the engine logs. */
static void
@@ -827,6 +833,37 @@ EFL_START_TEST(evas_test_gl_drm_free_with_frame_held)
}
EFL_END_TEST
+static void
+_canvas_cycle(int resizes)
+{
+ Test_Canvas *c = _canvas_new();
+ int i;
+
+ if (!c) return;
+
+ _render(c);
+ for (i = 0; i < resizes; i++)
+ {
+ _canvas_resize(c, 64 + (i * 8), 48 + (i * 6));
+ _render(c);
+ ck_assert_uint_eq(c->frame_count, (unsigned int)i + 2);
+ }
+ _canvas_free(c);
+}
+
+/* A canvas that was resized leaves nothing behind once it is freed. */
+EFL_START_TEST(evas_test_gl_drm_resize_then_free)
+{
+ int before, after;
+
+ before = _render_nodes_fd_count();
+ _canvas_cycle(8);
+ after = _render_nodes_fd_count();
+
+ ck_assert_int_eq(after, before);
+}
+EFL_END_TEST
+
EFL_START_TEST(evas_test_gl_drm_no_card_node)
{
Test_Canvas *c;
@@ -942,6 +979,7 @@ evas_test_gl_drm(TCase *tc)
tcase_add_test(tc, evas_test_gl_drm_slow_consumer_steady);
tcase_add_test(tc, evas_test_gl_drm_resize);
tcase_add_test(tc, evas_test_gl_drm_free_with_frame_held);
+ tcase_add_test(tc, evas_test_gl_drm_resize_then_free);
tcase_add_test(tc, evas_test_gl_drm_no_card_node);
tcase_add_test(tc, evas_test_gl_drm_same_node);
tcase_add_test(tc, evas_test_gl_drm_rotation_refused);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.