summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android/qandroidplatformwindow.cpp
diff options
context:
space:
mode:
authorTinja Paavoseppä <tinja.paavoseppa@qt.io>2024-04-09 16:03:15 +0300
committerPetri Virkkunen <petri.virkkunen@qt.io>2024-10-02 09:12:43 +0300
commite5513a9447771dc722ca27e553fd3e966ee7d44a (patch)
tree9c30083d6ebce74ee3687512de3913c151cc9639 /src/plugins/platforms/android/qandroidplatformwindow.cpp
parentcc0629a4877ff7609094a29e4a18252c0de057b0 (diff)
Android: Guard EGLSurface with a mutex
QAndroidPlatformOpenGlWindow creates an EGLSurface to wrap the native Android Surface. Once this EGLSurface is returned to QPlatformEglContext, nothing is guarding it anymore, and Android can freely destroy the underlying Surface. This leads to failed EGL operations when leaving from the app or returning to it, as that is when Android destroys/recreates the Surface. Use the mutex from QAndroidPlatformWindow to guard setting the Surface, and during the makeCurrent() and swapBuffers() calls. Locking until returning from these functions ensures Android cannot destroy the Surface in the middle of them. Task-number: QTBUG-118231 Pick-to: 6.8 Change-Id: I614575c42f7f0c2c17022994d3bc542726ebf039 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'src/plugins/platforms/android/qandroidplatformwindow.cpp')
-rw-r--r--src/plugins/platforms/android/qandroidplatformwindow.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp
index e86e617ca3e..7f43f175079 100644
--- a/src/plugins/platforms/android/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp
@@ -304,14 +304,12 @@ void QAndroidPlatformWindow::onSurfaceChanged(QtJniTypes::Surface surface)
{
lockSurface();
m_androidSurfaceObject = surface;
- if (m_androidSurfaceObject.isValid()) // wait until we have a valid surface to draw into
- m_surfaceWaitCondition.wakeOne();
- unlockSurface();
-
if (m_androidSurfaceObject.isValid()) {
- // repaint the window, when we have a valid surface
- sendExpose();
+ // wait until we have a valid surface to draw into
+ m_surfaceWaitCondition.wakeOne();
}
+
+ unlockSurface();
}
void QAndroidPlatformWindow::sendExpose() const