summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHiroyuki Ishii <ishii.hiroyuki002@jp.panasonic.com>2021-06-29 17:13:03 +0900
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2021-11-01 20:08:45 +0000
commita9ff714186334bce8fba9e7ebbbfbf50f05ba9db (patch)
tree8d124121e40402bcede13efddfc04a16ba1b24bc
parent9e79df7d3603ed49ff26f3ead447ad9d873a3395 (diff)
qt5: Fix timer leak in qtwayland to avoid animations being sluggish
With long-running qt applications which have fluid animations in wayland environment, the animation becomes obviously sluggish because massive amount of memcpy() is called through a constructor being placed in a loop in QTimerInfoList::timerInsert() function. This is caused by a timer-index leak bug of qtwayland, which is already reported to the qt project as following ticket. https://bugreports.qt.io/browse/QTBUG-79838 Unfortunately QTBUG-79838 is still open because maintenance of non-commercial version of qt5 is already stopped. However, we've confirmed that the patch attached to that ticket works fine except for that part of it is no longer needed due to the deletion of the code. So let's apply only effective part of it. Bug-AGL: SPEC-3991 Signed-off-by: Hiroyuki Ishii <ishii.hiroyuki002@jp.panasonic.com> Change-Id: Ib148b81aabb98e8df10c1414cdbfe26f7ddf09a6 Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/26466 Tested-by: Jenkins Job builder account ci-image-build: Jenkins Job builder account ci-image-boot-test: Jenkins Job builder account Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/26759 Reviewed-by: Scott Murray <scott.murray@konsulko.com> Reviewed-by: Naoto YAMAGUCHI <naoto.yamaguchi@aisin.co.jp>
-rw-r--r--meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland/0001-Fix-timer-leak-and-a-potential-race.patch42
-rw-r--r--meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_%.bbappend1
-rw-r--r--meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_aglcore.inc6
3 files changed, 49 insertions, 0 deletions
diff --git a/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland/0001-Fix-timer-leak-and-a-potential-race.patch b/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland/0001-Fix-timer-leak-and-a-potential-race.patch
new file mode 100644
index 000000000..642eabc4b
--- /dev/null
+++ b/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland/0001-Fix-timer-leak-and-a-potential-race.patch
@@ -0,0 +1,42 @@
+From f4d3297e6705cc524729d629bf94db11841dbb24 Mon Sep 17 00:00:00 2001
+From: Simon Yuan <simon.yuan@navico.com>
+Date: Thu, 7 Nov 2019 09:22:37 +1300
+Subject: [PATCH] Fix timer leak and a potential race
+
+The callback timer is now killed immediately before starting a new timer, this
+makes sure there is always a single active callback timer. It's unclear why
+killing the timer in a separate lambda doesn't always kill the timer in time,
+the hypothesis is that if killing the timer comes after starting a new one, then
+the previous timer is now left dangling. Whatever the reason is, it makes even
+more sense to kill the timer in the same lamda and immediately before starting a
+new timer anyway.
+---
+ src/client/qwaylandwindow.cpp | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
+index 0df99d9f..93b46bf1 100644
+--- a/src/client/qwaylandwindow.cpp
++++ b/src/client/qwaylandwindow.cpp
+@@ -1136,13 +1136,12 @@ void QWaylandWindow::handleUpdate()
+ mWaitingForFrameCallback = true;
+ mWaitingForUpdate = false;
+
+- // Stop current frame timer if any, can't use killTimer directly, see comment above.
+- int fcbId = mFrameCallbackTimerId.fetchAndStoreOrdered(-1);
+- if (fcbId != -1)
+- QMetaObject::invokeMethod(this, [this, fcbId] { killTimer(fcbId); }, Qt::QueuedConnection);
+-
+ // Start a timer for handling the case when the compositor stops sending frame callbacks.
+- QMetaObject::invokeMethod(this, [this] { // Again; can't do it directly
++ // Can't use killTimer directly, see comment above.
++ QMetaObject::invokeMethod(this, [this] {
++ int fcbId = mFrameCallbackTimerId.fetchAndStoreOrdered(-1);
++ if (fcbId != -1)
++ killTimer(fcbId);
+ if (mWaitingForFrameCallback)
+ mFrameCallbackTimerId = startTimer(100);
+ }, Qt::QueuedConnection);
+--
+2.25.1
+
diff --git a/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_%.bbappend b/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_%.bbappend
new file mode 100644
index 000000000..aa55c3a0c
--- /dev/null
+++ b/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_%.bbappend
@@ -0,0 +1 @@
+require ${@bb.utils.contains('AGL_FEATURES', 'aglcore', 'qtwayland_aglcore.inc', '', d)}
diff --git a/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_aglcore.inc b/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_aglcore.inc
new file mode 100644
index 000000000..ef5d0c7b5
--- /dev/null
+++ b/meta-agl-core/dynamic-layers/meta-qt5/recipes-qt/qt5/qtwayland_aglcore.inc
@@ -0,0 +1,6 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/qtwayland:"
+
+# Patch reported in https://bugreports.qt.io/browse/QTBUG-79838, not upstreamed
+SRC_URI += " \
+ file://0001-Fix-timer-leak-and-a-potential-race.patch \
+ "