GNOME Bugzilla – Bug 794614
gst_gl_window_set_window_handle() problem on Wayland EGL
Last modified: 2018-11-03 14:19:34 UTC
In "gstglwindow.c" ---------------------------------------------------------------- void gst_gl_window_set_window_handle (GstGLWindow * window, guintptr handle) { : gst_gl_window_send_message_async (window, (GstGLWindowCB) _set_window_handle_cb, data, (GDestroyNotify) _free_swh_cb); } ---------------------------------------------------------------- In "gstglwindow.c" ---------------------------------------------------------------- static void _set_window_handle_cb (GstSetWindowHandleCb * data) { : gst_gl_context_activate (context, FALSE); : window_class->set_window_handle (data->window, data->handle); : gst_gl_context_activate (context, TRUE); : } ---------------------------------------------------------------- In "gstglcontext_egl.c" ---------------------------------------------------------------- static gboolean gst_gl_context_egl_activate (GstGLContext * context, gboolean activate) { : if (activate) { /* Check if the backing handle changed */ handle = (EGLNativeWindowType) gst_gl_window_get_window_handle (window); if (handle && handle != egl->window_handle) { GST_DEBUG_OBJECT (context, "Handle changed ", : } result = eglMakeCurrent (egl->egl_display, egl->egl_surface, egl->egl_surface, egl->egl_context); } : } ---------------------------------------------------------------- NOTE: GstGLContextEGL assumes window handle change. In "gstglwindow_wayland_egl.c" ---------------------------------------------------------------- static guintptr gst_gl_window_wayland_egl_get_window_handle (GstGLWindow * window) { return (guintptr) GST_GL_WINDOW_WAYLAND_EGL (window)->window.native; } ---------------------------------------------------------------- NOTE: "window handle" is window.native . In "gstglwindow_wayland_egl.c" ---------------------------------------------------------------- static void gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window, guintptr handle) { : destroy_surfaces (window_egl); window_egl->window.foreign_surface = surface; create_surfaces (window_egl); : } ---------------------------------------------------------------- NOTE: window.native is destroyed in destroy_surfaces(). create_surfaces() may allocate same id for window.native . If so, gst_gl_context_egl_activate() cannot detect change. Modification suggestion: In "gstglwindow_wayland_egl.c" ---------------------------------------------------------------- static void gst_gl_window_wayland_egl_set_window_handle (GstGLWindow * window, guintptr handle) { : struct wl_egl_window *savewin; : : savewin = window_egl->window.native; /* defer destroy window to generate different id */ window_egl->window.native = NULL; /* avoid destroy */ destroy_surfaces (window_egl); window_egl->window.foreign_surface = surface; create_surfaces (window_egl); if (savewin) { wl_egl_window_destroy (savewin); /* deferred destroy */ } } ----------------------------------------------------------------
My question is what does this solve? Do you want to create a patch for this?
If window handle is changed on GstGLWindowWaylandEGL, but the change is not detected by GstGLContextEGL, eglMakeCurrent() in gst_gl_context_egl_activate() fails with EGL_BAD_NATIVE_WINDOW. Above modification solved this problem. (but I'm not sure why eglDestroySurface() does not fail) Further investigation may be needed.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/670.