From 7df7c28e4ae415df1469be9a156c4b1190362163 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 8 Nov 2023 12:40:40 +0100 Subject: Don't lock render thread when blocking swap is used By default, Qt will use a non-blocking eglSwapBuffers() and implement our own frame event mechanism with a time-out. When the blocking version of eglSwapBuffers() is in use (either because it's manually enabled or because the driver does not support the alternative), it depends on the main thread to poll events, as it will wait indefinitely for a frame callback. This is incompatible with our locking of the surface for the duration of the frame, since we may end up locking the main thread in QWaylandWindow::reset() during shutdown while the render thread is simultaneously locked in eglSwapBuffers(). The lock was implemented to work around a bug in one family of graphics drivers, so we simply disable it when blocking eglSwapBuffers() is used. If we need to put this back, we would need a more advanced approach and make sure we continue to poll events even while we're waiting for access to the surface. Pick-to: 6.5 Fixes: QTBUG-118890 Change-Id: I04f7d2b168726d82c38fe3fafd350dcab928b956 Reviewed-by: David Edmundson (cherry picked from commit 02263f21f5cdd61d71e5e8e08b2e73c05c6c1e76) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit b0f96ca63ee89f06254d65a8aca780c0d61933b4) --- src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp index e10b89813..039ec1a6a 100644 --- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp +++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp @@ -274,13 +274,15 @@ QWaylandGLContext::~QWaylandGLContext() void QWaylandGLContext::beginFrame() { Q_ASSERT(m_currentWindow != nullptr); - m_currentWindow->beginFrame(); + if (m_supportNonBlockingSwap) + m_currentWindow->beginFrame(); } void QWaylandGLContext::endFrame() { Q_ASSERT(m_currentWindow != nullptr); - m_currentWindow->endFrame(); + if (m_supportNonBlockingSwap) + m_currentWindow->endFrame(); } bool QWaylandGLContext::makeCurrent(QPlatformSurface *surface) -- cgit v1.2.3