diff options
author | Michal Klocek <michal.klocek@qt.io> | 2020-03-12 16:26:07 +0100 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2020-03-27 15:00:24 +0100 |
commit | 4dfe65f6d4d27bde9d4dae51d262493bea70e619 (patch) | |
tree | 264d2e3ba863f54b9000b6e82ad096fd93622a02 | |
parent | 9d979c1e89922500604527d1d8606a7c668ad11f (diff) |
Fix rare crash on exit in isCreateContextRobustnessSupported
During shutdown we might need to flush the gpu buffer if root frame sink
is being deleted, which needs current context, which calls
isCreateContextRobustnessSupported and ends up in calling platformName()
from gpu thread, which might be already destructed on ui thread.
Keep context helper till gpu thread is gone.
Task-number: QTBUG-79864
Change-Id: Idadc064694fe0584fb894a9405a0af80d9848626
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | src/core/ozone/gl_context_qt.cpp | 19 | ||||
-rw-r--r-- | src/core/ozone/gl_context_qt.h | 1 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 3 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/core/ozone/gl_context_qt.cpp b/src/core/ozone/gl_context_qt.cpp index 9813a3256..e9337874a 100644 --- a/src/core/ozone/gl_context_qt.cpp +++ b/src/core/ozone/gl_context_qt.cpp @@ -81,6 +81,15 @@ void GLContextHelper::initialize() { if (!contextHelper) contextHelper = new GLContextHelper; +#if QT_CONFIG(opengl) + if (QGuiApplication::platformName() == QLatin1String("offscreen")){ + contextHelper->m_robustness = false; + return; + } + + if (QOpenGLContext *context = qt_gl_global_share_context()) + contextHelper->m_robustness = context->format().testOption(QSurfaceFormat::ResetNotification); +#endif } void GLContextHelper::destroy() @@ -165,15 +174,9 @@ QFunctionPointer GLContextHelper::getEglGetProcAddress() bool GLContextHelper::isCreateContextRobustnessSupported() { -#if QT_CONFIG(opengl) - if (QGuiApplication::platformName() == QLatin1String("offscreen")) - return false; - - if (QOpenGLContext *context = qt_gl_global_share_context()) - return context->format().testOption(QSurfaceFormat::ResetNotification); -#endif - return false; + return contextHelper->m_robustness; } + QT_END_NAMESPACE #if defined(OS_WIN) diff --git a/src/core/ozone/gl_context_qt.h b/src/core/ozone/gl_context_qt.h index 8559af313..cc4f6b0d1 100644 --- a/src/core/ozone/gl_context_qt.h +++ b/src/core/ozone/gl_context_qt.h @@ -70,6 +70,7 @@ private: Q_INVOKABLE bool initializeContextOnBrowserThread(gl::GLContext* context, gl::GLSurface* surface, gl::GLContextAttribs attribs); static GLContextHelper* contextHelper; + bool m_robustness = false; }; QT_END_NAMESPACE diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 5937d3b21..1fa12885f 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -344,12 +344,13 @@ void WebEngineContext::destroy() // This should deliver all nessesery calls of DeleteSoon from PostTask while (delegate->DoWork()) { } - GLContextHelper::destroy(); m_devtoolsServer.reset(); m_runLoop->AfterRun(); // Destroy the main runner, this stops main message loop m_browserRunner.reset(); + // gpu thread is no longer around, so no more cotnext is used, remove the helper + GLContextHelper::destroy(); // These would normally be in the content-runner, but we allocated them separately: m_startupData.reset(); |