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

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