From 1a7c2d8589db7205b8fe7f907e2cb15b277953d5 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Fri, 19 Jul 2019 18:15:38 +0200 Subject: dev-qt/qtwayland: Various upstream regression fixes See also: https://mail.kde.org/pipermail/kde-distro-packagers/2019-July/000379 Signed-off-by: Andreas Sturmlechner Package-Manager: Portage-2.3.66, Repoman-2.3.11 --- ...ke-handleupdate-aware-of-exposure-changes.patch | 82 +++++++++++++ ...t-no-fake-surfacecreated-destroyed-events.patch | 92 ++++++++++++++ ...t-frame-callback-timer-when-window-hiding.patch | 39 ++++++ ....12.4-fix-stuttering-when-gui-thread-busy.patch | 133 +++++++++++++++++++++ dev-qt/qtwayland/qtwayland-5.12.4-r1.ebuild | 50 ++++++++ 5 files changed, 396 insertions(+) create mode 100644 dev-qt/qtwayland/files/qtwayland-5.12.4-client-make-handleupdate-aware-of-exposure-changes.patch create mode 100644 dev-qt/qtwayland/files/qtwayland-5.12.4-client-no-fake-surfacecreated-destroyed-events.patch create mode 100644 dev-qt/qtwayland/files/qtwayland-5.12.4-client-reset-frame-callback-timer-when-window-hiding.patch create mode 100644 dev-qt/qtwayland/files/qtwayland-5.12.4-fix-stuttering-when-gui-thread-busy.patch create mode 100644 dev-qt/qtwayland/qtwayland-5.12.4-r1.ebuild (limited to 'dev-qt/qtwayland') diff --git a/dev-qt/qtwayland/files/qtwayland-5.12.4-client-make-handleupdate-aware-of-exposure-changes.patch b/dev-qt/qtwayland/files/qtwayland-5.12.4-client-make-handleupdate-aware-of-exposure-changes.patch new file mode 100644 index 000000000000..6aacad2a942e --- /dev/null +++ b/dev-qt/qtwayland/files/qtwayland-5.12.4-client-make-handleupdate-aware-of-exposure-changes.patch @@ -0,0 +1,82 @@ +From b13b595dc4f4fe6bdca7b69a21fd934ee233e149 Mon Sep 17 00:00:00 2001 +From: David Edmundson +Date: Sun, 23 Jun 2019 14:48:30 +0200 +Subject: [PATCH] Client: Make handleUpdate aware of exposure changes + +The wl_surface can be destroyed whilst a render is happening. Calling +wl_surface::frame after the window is reset can crash as wl_surface is +null. + +Change-Id: I139a9b234cb6acba81d6c1d5fa58629904a25053 +--- + src/client/qwaylandwindow.cpp | 10 +++++++++- + src/client/qwaylandwindow_p.h | 4 ++++ + 2 files changed, 13 insertions(+), 1 deletion(-) + +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp +index 5ea0dce1e..7e7a4929c 100644 +--- a/src/client/qwaylandwindow.cpp ++++ b/src/client/qwaylandwindow.cpp +@@ -79,6 +79,8 @@ Q_LOGGING_CATEGORY(lcWaylandBackingstore, "qt.qpa.wayland.backingstore") + + QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr; + ++QReadWriteLock mSurfaceLock; ++ + QWaylandWindow::QWaylandWindow(QWindow *window) + : QPlatformWindow(window) + , mDisplay(waylandScreen()->display()) +@@ -210,6 +212,7 @@ void QWaylandWindow::initWindow() + + void QWaylandWindow::initializeWlSurface() + { ++ QWriteLocker lock(&mSurfaceLock); + init(mDisplay->createSurface(static_cast(this))); + } + +@@ -245,8 +248,10 @@ void QWaylandWindow::reset(bool sendDestroyEvent) + mShellSurface = nullptr; + delete mSubSurfaceWindow; + mSubSurfaceWindow = nullptr; +- if (isInitialized()) ++ if (isInitialized()) { ++ QWriteLocker lock(&mSurfaceLock); + destroy(); ++ } + mScreens.clear(); + + if (mFrameCallback) { +@@ -1145,6 +1150,9 @@ void QWaylandWindow::requestUpdate() + void QWaylandWindow::handleUpdate() + { + // TODO: Should sync subsurfaces avoid requesting frame callbacks? ++ QReadLocker lock(&mSurfaceLock); ++ if (!isInitialized()) ++ return; + + if (mFrameCallback) { + wl_callback_destroy(mFrameCallback); +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h +index e8c9d5684..d3706442f 100644 +--- a/src/client/qwaylandwindow_p.h ++++ b/src/client/qwaylandwindow_p.h +@@ -53,6 +53,8 @@ + + #include + #include ++#include ++ + #include + #include + #include +@@ -271,6 +273,8 @@ private: + static QMutex mFrameSyncMutex; + static QWaylandWindow *mMouseGrab; + ++ QReadWriteLock mSurfaceLock; ++ + friend class QWaylandSubSurface; + }; + +-- +2.16.3 diff --git a/dev-qt/qtwayland/files/qtwayland-5.12.4-client-no-fake-surfacecreated-destroyed-events.patch b/dev-qt/qtwayland/files/qtwayland-5.12.4-client-no-fake-surfacecreated-destroyed-events.patch new file mode 100644 index 000000000000..c358e0f72de0 --- /dev/null +++ b/dev-qt/qtwayland/files/qtwayland-5.12.4-client-no-fake-surfacecreated-destroyed-events.patch @@ -0,0 +1,92 @@ +From e6edc73942a76e57e7ac745217092333480f2c64 Mon Sep 17 00:00:00 2001 +From: David Edmundson +Date: Sun, 23 Jun 2019 15:09:51 +0200 +Subject: [PATCH] Client: Don't send fake SurfaceCreated/Destroyed events + +QPlatformSurface relates to the backing store. Not the wl_surface. +They are emitted by QPlatformWindow. + +Due to a previously incorrect usage by KDE developers it was faked to +emit the events when the wl_surface is created/hidden to keep behavior. + +With QtBase a9246c7132a2c8864d3ae6cebd260bb9ee711fcb this now causes an +issue as now QWidgets react to this event in a breaking way. + +Change-Id: I2f003bc9da85f032a0053677fd281152099fc9eb +--- + .../wayland/custom-extension/client-common/customextension.cpp | 9 +++++++-- + src/client/qwaylandwindow.cpp | 10 ++-------- + src/client/qwaylandwindow_p.h | 2 +- + 3 files changed, 10 insertions(+), 11 deletions(-) + +diff --git a/examples/wayland/custom-extension/client-common/customextension.cpp b/examples/wayland/custom-extension/client-common/customextension.cpp +index aa0cb58a4..16f18fd7a 100644 +--- a/examples/wayland/custom-extension/client-common/customextension.cpp ++++ b/examples/wayland/custom-extension/client-common/customextension.cpp +@@ -81,8 +81,13 @@ QWindow *CustomExtension::windowForSurface(struct ::wl_surface *surface) + + bool CustomExtension::eventFilter(QObject *object, QEvent *event) + { +- if (event->type() == QEvent::PlatformSurface +- && static_cast(event)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) { ++ if (event->type() == QEvent::Expose) { ++ auto ee = static_cast(event); ++ ++ if ((ee->region().isNull())) { ++ return false; ++ } ++ + QWindow *window = qobject_cast(object); + Q_ASSERT(window); + window->removeEventFilter(this); +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp +index ca7c8495c..a6331621d 100644 +--- a/src/client/qwaylandwindow.cpp ++++ b/src/client/qwaylandwindow.cpp +@@ -93,7 +93,7 @@ QWaylandWindow::~QWaylandWindow() + delete mWindowDecoration; + + if (isInitialized()) +- reset(false); ++ reset(); + + const QWindow *parent = window(); + foreach (QWindow *w, QGuiApplication::topLevelWindows()) { +@@ -119,8 +119,6 @@ void QWaylandWindow::initWindow() + + if (!isInitialized()) { + initializeWlSurface(); +- QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated); +- QGuiApplication::sendEvent(window(), &e); + } + + if (shouldCreateSubSurface()) { +@@ -227,12 +225,8 @@ bool QWaylandWindow::shouldCreateSubSurface() const + return QPlatformWindow::parent() != nullptr; + } + +-void QWaylandWindow::reset(bool sendDestroyEvent) ++void QWaylandWindow::reset() + { +- if (isInitialized() && sendDestroyEvent) { +- QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed); +- QGuiApplication::sendEvent(window(), &e); +- } + delete mShellSurface; + mShellSurface = nullptr; + delete mSubSurfaceWindow; +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h +index 121ad8219..ba69fd9dc 100644 +--- a/src/client/qwaylandwindow_p.h ++++ b/src/client/qwaylandwindow_p.h +@@ -263,7 +263,7 @@ private: + void initializeWlSurface(); + bool shouldCreateShellSurface() const; + bool shouldCreateSubSurface() const; +- void reset(bool sendDestroyEvent = true); ++ void reset(); + void sendExposeEvent(const QRect &rect); + static void closePopups(QWaylandWindow *parent); + QWaylandScreen *calculateScreenFromSurfaceEvents() const; +-- +2.16.3 diff --git a/dev-qt/qtwayland/files/qtwayland-5.12.4-client-reset-frame-callback-timer-when-window-hiding.patch b/dev-qt/qtwayland/files/qtwayland-5.12.4-client-reset-frame-callback-timer-when-window-hiding.patch new file mode 100644 index 000000000000..8d4378243412 --- /dev/null +++ b/dev-qt/qtwayland/files/qtwayland-5.12.4-client-reset-frame-callback-timer-when-window-hiding.patch @@ -0,0 +1,39 @@ +From a4e6f88f50d1a1dd56df77ce8b07b98aceb20ddc Mon Sep 17 00:00:00 2001 +From: David Edmundson +Date: Sun, 23 Jun 2019 13:25:16 +0200 +Subject: [PATCH] Client: Reset frame callback timer when hiding a window + +If we hide a window whilst a compositor has a pending frame to show, +it's possible the compositor will not render the frame and not return +the callback. + +If this happens on the next window expose we can be left with +mFrameCallbackTimedOut still true causing isExposed() to remain false +and us to not send the next buffer when we later show the window again. + +Change-Id: I507410415d1a930fd5fa736412055e68fdf6c1d3 +Reviewed-by: Johan Helsing +--- + src/client/qwaylandwindow.cpp | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp +index 7c8ecadaa..2b243bc44 100644 +--- a/src/client/qwaylandwindow.cpp ++++ b/src/client/qwaylandwindow.cpp +@@ -254,6 +254,13 @@ void QWaylandWindow::reset(bool sendDestroyEvent) + mFrameCallback = nullptr; + } + ++ int timerId = mFrameCallbackTimerId.fetchAndStoreOrdered(-1); ++ if (timerId != -1) { ++ killTimer(timerId); ++ } ++ mWaitingForFrameCallback = false; ++ mFrameCallbackTimedOut = false; ++ + mMask = QRegion(); + mQueuedBuffer = nullptr; + } +-- +2.16.3 diff --git a/dev-qt/qtwayland/files/qtwayland-5.12.4-fix-stuttering-when-gui-thread-busy.patch b/dev-qt/qtwayland/files/qtwayland-5.12.4-fix-stuttering-when-gui-thread-busy.patch new file mode 100644 index 000000000000..794fb1275298 --- /dev/null +++ b/dev-qt/qtwayland/files/qtwayland-5.12.4-fix-stuttering-when-gui-thread-busy.patch @@ -0,0 +1,133 @@ +From ec9057081f1094fbfeb11449bc533997731e4079 Mon Sep 17 00:00:00 2001 +From: Johan Klokkhammer Helsing +Date: Wed, 19 Jun 2019 14:05:22 +0200 +Subject: [PATCH] Client: Fix stuttering when the GUI thread is busy + +When we did invokeMethod for handling the frame callbacks, we had to wait for +the GUI thread to finish whatever it's doing before we would stop blocking. + +Fix it by clearing the frame callback timer and stop blocking immediately, +while delaying the rest of the work until it can be run on the other thread. + +Fixes: QTBUG-76397 +Change-Id: I343e4feac4838926b4fa2ccac2948988bc6c3bb7 +Reviewed-by: Paul Olav Tvete +--- + src/client/qwaylandwindow.cpp | 59 +++++++++++++++++++++++-------------------- + src/client/qwaylandwindow_p.h | 2 +- + 2 files changed, 32 insertions(+), 29 deletions(-) + +diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp +index cecdbda92..7c8ecadaa 100644 +--- a/src/client/qwaylandwindow.cpp ++++ b/src/client/qwaylandwindow.cpp +@@ -610,29 +610,34 @@ const wl_callback_listener QWaylandWindow::callbackListener = { + Q_UNUSED(callback); + Q_UNUSED(time); + auto *window = static_cast(data); +- if (window->thread() != QThread::currentThread()) +- QMetaObject::invokeMethod(window, [=] { window->handleFrameCallback(); }, Qt::QueuedConnection); +- else +- window->handleFrameCallback(); ++ window->handleFrameCallback(); + } + }; + + void QWaylandWindow::handleFrameCallback() + { +- bool wasExposed = isExposed(); ++ // Stop the timer and stop waiting immediately ++ int timerId = mFrameCallbackTimerId.fetchAndStoreOrdered(-1); ++ mWaitingForFrameCallback = false; + +- if (mFrameCallbackTimerId != -1) { +- killTimer(mFrameCallbackTimerId); +- mFrameCallbackTimerId = -1; +- } ++ // The rest can wait until we can run it on the correct thread ++ auto doHandleExpose = [this, timerId]() { ++ if (timerId != -1) ++ killTimer(timerId); + +- mWaitingForFrameCallback = false; +- mFrameCallbackTimedOut = false; ++ bool wasExposed = isExposed(); ++ mFrameCallbackTimedOut = false; ++ if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed? ++ sendExposeEvent(QRect(QPoint(), geometry().size())); ++ if (wasExposed && hasPendingUpdateRequest()) ++ deliverUpdateRequest(); ++ }; + +- if (!wasExposed && isExposed()) +- sendExposeEvent(QRect(QPoint(), geometry().size())); +- if (wasExposed && hasPendingUpdateRequest()) +- deliverUpdateRequest(); ++ if (thread() != QThread::currentThread()) { ++ QMetaObject::invokeMethod(this, doHandleExpose); ++ } else { ++ doHandleExpose(); ++ } + } + + QMutex QWaylandWindow::mFrameSyncMutex; +@@ -654,11 +659,11 @@ bool QWaylandWindow::waitForFrameSync(int timeout) + } + + // Stop current frame timer if any, can't use killTimer directly, because we might be on a diffent thread +- if (mFrameCallbackTimerId != -1) { +- int id = mFrameCallbackTimerId; +- mFrameCallbackTimerId = -1; +- QMetaObject::invokeMethod(this, [=] { killTimer(id); }, Qt::QueuedConnection); +- } ++ // Ordered semantics is needed to avoid stopping the timer twice and not miss it when it's ++ // started by other writes ++ int fcbId = mFrameCallbackTimerId.fetchAndStoreOrdered(-1); ++ if (fcbId != -1) ++ QMetaObject::invokeMethod(this, [=] { killTimer(fcbId); }, Qt::QueuedConnection); + + return !mWaitingForFrameCallback; + } +@@ -1090,9 +1095,9 @@ void QWaylandWindow::timerEvent(QTimerEvent *event) + } + } + +- if (event->timerId() == mFrameCallbackTimerId) { +- killTimer(mFrameCallbackTimerId); +- mFrameCallbackTimerId = -1; ++ ++ if (mFrameCallbackTimerId.testAndSetOrdered(event->timerId(), -1)) { ++ killTimer(event->timerId()); + qCDebug(lcWaylandBackingstore) << "Didn't receive frame callback in time, window should now be inexposed"; + mFrameCallbackTimedOut = true; + mWaitingForUpdate = false; +@@ -1154,11 +1159,9 @@ void QWaylandWindow::handleUpdate() + mWaitingForUpdate = false; + + // Stop current frame timer if any, can't use killTimer directly, see comment above. +- if (mFrameCallbackTimerId != -1) { +- int id = mFrameCallbackTimerId; +- mFrameCallbackTimerId = -1; +- QMetaObject::invokeMethod(this, [=] { killTimer(id); }, Qt::QueuedConnection); +- } ++ int fcbId = mFrameCallbackTimerId.fetchAndStoreOrdered(-1); ++ if (fcbId != -1) ++ QMetaObject::invokeMethod(this, [=] { killTimer(fcbId); }, Qt::QueuedConnection); + + // Start a timer for handling the case when the compositor stops sending frame callbacks. + QMetaObject::invokeMethod(this, [=] { // Again; can't do it directly +diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h +index c47123dc9..e8c9d5684 100644 +--- a/src/client/qwaylandwindow_p.h ++++ b/src/client/qwaylandwindow_p.h +@@ -216,7 +216,7 @@ protected: + WId mWindowId; + bool mWaitingForFrameCallback = false; + bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out +- int mFrameCallbackTimerId = -1; // Started on commit, reset on frame callback ++ QAtomicInt mFrameCallbackTimerId = -1; // Started on commit, reset on frame callback + struct ::wl_callback *mFrameCallback = nullptr; + struct ::wl_event_queue *mFrameQueue = nullptr; + QWaitCondition mFrameSyncWait; +-- +2.16.3 diff --git a/dev-qt/qtwayland/qtwayland-5.12.4-r1.ebuild b/dev-qt/qtwayland/qtwayland-5.12.4-r1.ebuild new file mode 100644 index 000000000000..6bc4d61f2112 --- /dev/null +++ b/dev-qt/qtwayland/qtwayland-5.12.4-r1.ebuild @@ -0,0 +1,50 @@ +# Copyright 1999-2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +inherit qt5-build + +DESCRIPTION="Wayland platform plugin for Qt" + +if [[ ${QT5_BUILD_TYPE} == release ]]; then + KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~ppc ~ppc64 ~x86" +fi + +IUSE="+libinput xcomposite" + +DEPEND=" + >=dev-libs/wayland-1.6.0 + ~dev-qt/qtcore-${PV} + ~dev-qt/qtdeclarative-${PV} + ~dev-qt/qtgui-${PV}[egl,libinput=] + media-libs/mesa[egl] + >=x11-libs/libxkbcommon-0.2.0 + xcomposite? ( + x11-libs/libX11 + x11-libs/libXcomposite + ) +" +RDEPEND="${DEPEND}" + +PATCHES=( + "${FILESDIR}"/${P}-client-no-fake-surfacecreated-destroyed-events.patch + "${FILESDIR}"/${P}-fix-stuttering-when-gui-thread-busy.patch + "${FILESDIR}"/${P}-client-reset-frame-callback-timer-when-window-hiding.patch + "${FILESDIR}"/${P}-client-make-handleupdate-aware-of-exposure-changes.patch +) + +src_prepare() { + qt_use_disable_config libinput xkbcommon-evdev \ + src/client/client.pro \ + src/compositor/wayland_wrapper/wayland_wrapper.pri \ + src/plugins/shellintegration/ivi-shell/ivi-shell.pro \ + src/plugins/shellintegration/wl-shell/wl-shell.pro \ + src/plugins/shellintegration/xdg-shell/xdg-shell.pro \ + src/plugins/shellintegration/xdg-shell-v5/xdg-shell-v5.pro \ + src/plugins/shellintegration/xdg-shell-v6/xdg-shell-v6.pro \ + tests/auto/compositor/compositor/compositor.pro + + use xcomposite || rm -r config.tests/xcomposite || die + + qt5-build_src_prepare +} -- cgit v1.2.3-65-gdbad