gl: wayland: Fix hinding the window on close()
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 14 Jul 2021 15:43:10 +0000 (11:43 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 15 Jul 2021 16:22:48 +0000 (16:22 +0000)
When the window is called, we properly destroy all surfaces, which effectively
will unmap that surface and should make it disapear on screen, but we also
destroy the wl_source, a GSource that is resposibble of dispatching and executing
messages to/from the Wayland server.

As a side effect, the server never gets the message and the surfaces are
"leaked" on the server. We fix this using wl_display_flush() before destroying
the wl_source.

Fixes #815

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1226>

gst-libs/gst/gl/wayland/gstglwindow_wayland_egl.c

index ecfa03b..20ce51d 100644 (file)
@@ -469,6 +469,11 @@ gst_gl_window_wayland_egl_close (GstGLWindow * gl_window)
 
   destroy_surfaces (window_egl);
 
+  /* As we are about to destroy the wl_source, we need to ensure everything
+   * has been sent synchronously, otherwise we will be leaking surfaces on
+   * server, leaving the window visible and unrefreshed on screen. */
+  wl_display_flush (GST_GL_DISPLAY_WAYLAND (gl_window->display)->display);
+
   g_source_destroy (window_egl->wl_source);
   g_source_unref (window_egl->wl_source);
   window_egl->wl_source = NULL;