Details
-
Bug
-
Resolution: Unresolved
-
P1: Critical
-
None
-
5.14.0, 5.14.1, 5.14.2
-
None
Description
This problem is difficult to reproduce due to a kind of race condition, so it's hard to make an example for this one.
We use Qt3DRender in our project to render .fbx model and save result into
QTexture2D (we don't use Scene3D). We also use QQuickFramebufferObject for integrating OpenGl rendering with QTQuick. And we observed that sometimes method QQuickFramebufferObject::Renderer::createFramebufferObject is called when current OpenGl context is not set. This cause crash in our application.
After debugging I found that QT3D resets Open GL context during QSG render loop.
What's happening:
QSGGuiThreadRenderLoop::renderWindow() // Start render loop
QOpenGLContext::makeCurrent(surface)
...
rc->flushFrameSynchronousEvents() // Call flushFrameSynchronousEvents within render loop
...
QRenderAspectPrivate::jobsDone() // flushFrameSynchronousEvents triggers jobsDone callback
Renderer::doRender()
SubmissionContext::beginDrawing()
QOpenGLContext::makeCurrent(surface) // Set QT3D OpenGl context
SubmissionContext::endDrawing()
QOpenGLContext::doneCurrent() // Reset current OpenGl context
...
cd->syncSceneGraph(); // Call syncSceneGraph within render loop
QQuickWindowPrivate::updateDirtyNodes()
...
QQuickWindowPrivate::updateDirtyNode(node)
QQuickFramebufferObject::updatePaintNode()
QQuickFramebufferObject::createFramebufferObject() // Method is called when current OpenGl context is reset
Possible fixed:
1. Qt3D should store the previous context and restore it when doing SubmissionContext::endDrawing().
2. QSGGuiThreadRenderLoop should prevent Qt3D from rendering (Renderer::doRender()) inside a render loop.
__