Blame SOURCES/0019-Client-Don-t-always-recreate-frame-callbacks.patch

f38a11
From bdd2dacf2d8668b3a1f59db3c6cc859f95868eb2 Mon Sep 17 00:00:00 2001
b814f0
From: Georges Basile Stavracas Neto <gbsneto@gnome.org>
b814f0
Date: Thu, 27 May 2021 19:55:04 -0300
f38a11
Subject: [PATCH 19/40] Client: Don't always recreate frame callbacks
b814f0
b814f0
The main QWaylandWindow method that is executed when handling updates is
b814f0
QWaylandWindow::handleUpdate(). This method always, unconditionally queues
b814f0
a frame callback, regardless of whether any other one is already queued.
b814f0
b814f0
On some circumstances, e.g. when a window is hidden or completely obscured
b814f0
by other windows, it stops receiving frame callbacks from the compositor.
b814f0
However, QWaylandWindow would continue to request for them, which eventually
b814f0
fills up the Wayland socket, and causes the application to crash.
b814f0
b814f0
This can be avoided by checking if the platform window is already waiting
b814f0
for a frame callback, before queueing another one.
b814f0
b814f0
In QWaylandWindow::handleUpdate(), check if mWaitingForFrameCallback is true
b814f0
before queueing frame callbacks, and early return if that's the case.
b814f0
b814f0
The XDG-shell test needed to be updated for this: The mock compositor is
b814f0
not responding to any frame callbacks, so the window will be unexposed,
b814f0
no longer get paint events and therefore not trigger any commit. This
b814f0
worked by accident before because we were issuing updates quickly enough
b814f0
to reset the timer before it had a chance to unexpose the window. The
b814f0
easiest fix is just to disable the dependency on frame callbacks in
b814f0
this test, since that is clearly not what it's testing.
b814f0
b814f0
Task-number: QTBUG-81504
b814f0
Change-Id: Ieacb05c7d5a5fcf662243d9177ebcc308cb9ca84
b814f0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
b814f0
Reviewed-by: Georges Basile Stavracas Neto <gbsneto@gnome.org>
b814f0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
b814f0
(cherry picked from commit cbc74ba6d7186457d8d07183272e952dee5f34f9)
b814f0
---
b814f0
 src/client/qwaylandwindow.cpp               | 4 ++++
b814f0
 tests/auto/client/xdgshell/tst_xdgshell.cpp | 2 ++
b814f0
 2 files changed, 6 insertions(+)
b814f0
b814f0
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
b814f0
index bd70f4af..85307875 100644
b814f0
--- a/src/client/qwaylandwindow.cpp
b814f0
+++ b/src/client/qwaylandwindow.cpp
b814f0
@@ -1170,6 +1170,10 @@ void QWaylandWindow::requestUpdate()
b814f0
 void QWaylandWindow::handleUpdate()
b814f0
 {
b814f0
     qCDebug(lcWaylandBackingstore) << "handleUpdate" << QThread::currentThread();
b814f0
+
b814f0
+    if (mWaitingForFrameCallback)
b814f0
+        return;
b814f0
+
b814f0
     // TODO: Should sync subsurfaces avoid requesting frame callbacks?
b814f0
     QReadLocker lock(&mSurfaceLock);
b814f0
     if (!mSurface)
b814f0
diff --git a/tests/auto/client/xdgshell/tst_xdgshell.cpp b/tests/auto/client/xdgshell/tst_xdgshell.cpp
b814f0
index 2fdd0a7c..e2593314 100644
b814f0
--- a/tests/auto/client/xdgshell/tst_xdgshell.cpp
b814f0
+++ b/tests/auto/client/xdgshell/tst_xdgshell.cpp
b814f0
@@ -138,6 +138,7 @@ void tst_xdgshell::configureSize()
b814f0
 
b814f0
 void tst_xdgshell::configureStates()
b814f0
 {
b814f0
+    QVERIFY(qputenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT", "0"));
b814f0
     QRasterWindow window;
b814f0
     window.resize(64, 48);
b814f0
     window.show();
b814f0
@@ -186,6 +187,7 @@ void tst_xdgshell::configureStates()
b814f0
     QCOMPARE(window.windowStates(), Qt::WindowNoState);
b814f0
     QCOMPARE(window.frameGeometry().size(), windowedSize);
b814f0
 //    QCOMPARE(window.frameGeometry().topLeft(), QPoint()); // TODO: this doesn't currently work when window decorations are enabled
b814f0
+    QVERIFY(qunsetenv("QT_WAYLAND_FRAME_CALLBACK_TIMEOUT"));
b814f0
 }
b814f0
 
b814f0
 void tst_xdgshell::popup()
b814f0
-- 
b814f0
2.35.1
b814f0