Blame SOURCES/0014-xwayland-eglstream-Keep-a-reference-to-the-pixmap.patch

d05f4b
From f76dd86f5bbdccb3655ac58365e4604d03de65f5 Mon Sep 17 00:00:00 2001
d05f4b
From: Olivier Fourdan <ofourdan@redhat.com>
d05f4b
Date: Wed, 14 Apr 2021 17:31:08 +0200
d05f4b
Subject: [PATCH xserver 14/27] xwayland/eglstream: Keep a reference to the
d05f4b
 pixmap
d05f4b
MIME-Version: 1.0
d05f4b
Content-Type: text/plain; charset=UTF-8
d05f4b
Content-Transfer-Encoding: 8bit
d05f4b
d05f4b
Commit affc47452 - "xwayland: Drop the separate refcount for the
d05f4b
xwl_pixmap" removed the separate reference counter for the xwl_pixmap
d05f4b
which holds the EGLStream.
d05f4b
d05f4b
While that works fine for the common case, if the window's pixmap is
d05f4b
changed before the stream is ready, the older pixmap will be destroyed
d05f4b
and the xwl_pixmap along with it, even if the compositor is still using
d05f4b
the stream.
d05f4b
d05f4b
The code that was removed with commit affc47452 was taking care of that
d05f4b
by increasing the separate reference counter for the xwl_pixmap, but it
d05f4b
no longer the case.
d05f4b
d05f4b
As a result, we may end up with the EGL stream in the wrong state when
d05f4b
trying to use it, which will cascade down into all sort of issues.
d05f4b
d05f4b
To avoid the problem, increase the reference count on the pixmap when it
d05f4b
is marked as invalid in EGLStream's SetWindowPixmap().
d05f4b
d05f4b
This way, the xwl_pixmap and the EGLStream are kept until released by
d05f4b
the compositor, even when the pixmap changes before stream is ready.
d05f4b
d05f4b
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
d05f4b
Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
d05f4b
Fixes: affc47452 xwayland: Drop the separate refcount for the xwl_pixmap
d05f4b
https://gitlab.freedesktop.org/xorg/xserver/-/issues/1156
d05f4b
(cherry picked from commit e19bf86c17ef9c802fea24410cc6b1f51a19ce7f)
d05f4b
---
d05f4b
 hw/xwayland/xwayland-glamor-eglstream.c | 12 ++++++++++--
d05f4b
 1 file changed, 10 insertions(+), 2 deletions(-)
d05f4b
d05f4b
diff --git a/hw/xwayland/xwayland-glamor-eglstream.c b/hw/xwayland/xwayland-glamor-eglstream.c
d05f4b
index 32f9a326f..807bfcb1d 100644
d05f4b
--- a/hw/xwayland/xwayland-glamor-eglstream.c
d05f4b
+++ b/hw/xwayland/xwayland-glamor-eglstream.c
d05f4b
@@ -355,6 +355,13 @@ xwl_eglstream_maybe_set_pending_stream_invalid(PixmapPtr pixmap)
d05f4b
         return;
d05f4b
 
d05f4b
     pending->is_valid = FALSE;
d05f4b
+
d05f4b
+    /* The compositor may still be using the stream, so we can't destroy
d05f4b
+     * it yet. We'll only have a guarantee that the stream is safe to
d05f4b
+     * destroy once we receive the pending wl_display_sync() for this
d05f4b
+     * stream
d05f4b
+     */
d05f4b
+    pending->pixmap->refcnt++;
d05f4b
 }
d05f4b
 
d05f4b
 static void
d05f4b
@@ -530,8 +537,9 @@ xwl_eglstream_consumer_ready_callback(void *data,
d05f4b
     pixmap = pending->pixmap;
d05f4b
 
d05f4b
     if (!pending->is_valid) {
d05f4b
-        xwl_eglstream_destroy_pixmap_stream(pending->xwl_pixmap);
d05f4b
-        goto out;
d05f4b
+        xwl_glamor_eglstream_remove_pending_stream(xwl_pixmap);
d05f4b
+        dixDestroyPixmap(pixmap, 0);
d05f4b
+        return;
d05f4b
     }
d05f4b
 
d05f4b
     xwl_glamor_egl_make_current(xwl_screen);
d05f4b
-- 
d05f4b
2.31.1
d05f4b