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

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