From aba6bd7822f4c0f572765bfaada76f454a594317 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Tue, 20 Jul 2021 09:37:58 -0400 Subject: [PATCH] glwindow: wayland: Skip redoing surfaces if window haven't changed The problem is that EGLNativeWindowSurface and wl_egl_surface are the same object underneath, so we must recreate both together. As an optimization, the EGLNativeWindowSurface wrapper is only re-created if the window_handle changed. On Mesa, this would cause crash, which will be fixed by: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11979 And will lead to proper errors in the future or on other GL stack. This issue was encounter using a permanent GstGLDisplay after cycling one of multiple independent pipelines through NULL state. Part-of: --- gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c index f2d7ceb4e1..621e4dba34 100644 --- a/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c +++ b/gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c @@ -614,8 +614,11 @@ gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window, GstGLWindowWaylandEGL *window_egl = GST_GL_WINDOW_WAYLAND_EGL (window); struct wl_surface *surface = (struct wl_surface *) handle; - /* already set the NULL handle */ - if (surface == NULL && window_egl->window.foreign_surface == NULL) + /* Don't unparent if the window handle haven't changed or both were %NULL. + * We have to do that, since GstGLContextEGL will not recreate its + * EGLNativeWindowSurface, which will lead to crash with some Mesa driver + * version, or errors otherwise. */ + if (window_egl->window.foreign_surface == surface) return; /* unparent */