Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-34898

SceneGraph doesn't ensure OpenGL context is bound before tear down

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Affects Version/s: 5.2.0 Beta1
    • Fix Version/s: 5.2.1
    • Component/s: Quick: SceneGraph
    • Labels:
      None
    • Environment:
      Linux/X11 on Sandybridge Mobile QtDeclarative module at 734f424ee97fc74027f2717c592c0b329e41573b
    • Commits:
      91e2c5d749e38eed93e91b14151faa549e70080f

      Description

      If the scene graph uses the main GUI thread for OpenGL rendering there can be unintended side-effects if the application uses another OpenGL context and that one is current in the GUI thread or no QOpenGLContext is current when the QQuickWindow gets hidden.

      The problem can be seen in the stacktrace below. In that case a call to QOpenGLContext::doneCurrent() was done after using the other context in the main GUI thread. So QOpenGLContext::currentContext() returns a nullptr.

      If the non-QtQuick OpenGL context is current at that time the cleanup functionality executes glDeleteBuffer on the wrong context causing a later crash if the buffer is used again.

      These problems can be circumvented by calling makeCurrent() on the QQuickWindow's OpenGL context prior to destruction.

      #6 0x00007fcec00f71e5 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
      #7 0x00007fcec00fa398 in __GI_abort () at abort.c:90
      #8 0x00007fcec1183402 in qt_message_fatal (context=..., message=...) at global/qlogging.cpp:979
      #9 0x00007fcec1180fce in QMessageLogger::fatal (this=0x7fff7d3782a0, msg=0x7fcec14d3678 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:384
      #10 0x00007fcec117c9e6 in qt_assert (assertion=0x7fcec1dbd94c "context", file=0x7fcec1dbd930 "opengl/qopenglfunctions.cpp", line=195) at global/qglobal.cpp:2088
      #11 0x00007fcec1cc8b85 in qt_gl_functions (context=0x0) at opengl/qopenglfunctions.cpp:195
      #12 0x00007fcec1cd1023 in (anonymous namespace)::Resolver<QOpenGLFunctionsPrivate, void (int, unsigned int const*), 3, void>::operator()<int, unsigned int const*> (this=0x7fff7d378430, p1=1, p2=0x294f3a0) at opengl/qopenglfunctions.cpp:1764
      #13 0x00007fcec1cca295 in qopenglfResolveDeleteBuffers (n=1, buffers=0x294f3a0) at opengl/qopenglfunctions.cpp:1959
      #14 0x00007fcec9c189b6 in QOpenGLFunctions::glDeleteBuffers (this=0x2754390, n=1, buffers=0x294f3a0) at /home/martin/kf5/src/qt5/qtbase/include/QtGui/../../src/gui/opengl/qopenglfunctions.h:643
      #15 0x00007fcec9c0f8fd in QSGBatchRenderer::qsg_wipeBuffer (buffer=0x294f3a0, funcs=0x2754390) at scenegraph/coreapi/qsgbatchrenderer.cpp:759
      #16 0x00007fcec9c0f937 in QSGBatchRenderer::qsg_wipeBatch (batch=0x294f380, funcs=0x2754390) at scenegraph/coreapi/qsgbatchrenderer.cpp:765
      #17 0x00007fcec9c0fa05 in QSGBatchRenderer::Renderer::~Renderer (this=0x2754380, __in_chrg=<optimized out>) at scenegraph/coreapi/qsgbatchrenderer.cpp:773
      #18 0x00007fcec9c0fc32 in QSGBatchRenderer::Renderer::~Renderer (this=0x2754380, __in_chrg=<optimized out>) at scenegraph/coreapi/qsgbatchrenderer.cpp:787
      #19 0x00007fcec9c9b9da in QQuickWindow::cleanupSceneGraph (this=0x2325010) at items/qquickwindow.cpp:2565
      #20 0x00007fcec9c9a4dd in QQuickWindowPrivate::cleanupNodesOnShutdown (this=0x236cee0) at items/qquickwindow.cpp:2297
      #21 0x00007fcec9c61c4c in QSGGuiThreadRenderLoop::hide (this=0x25f9ce0, window=0x2325010) at scenegraph/qsgrenderloop.cpp:240
      #22 0x00007fcec9c920c3 in QQuickWindow::hideEvent (this=0x2325010) at items/qquickwindow.cpp:230
      #23 0x00007fcec1a09f9e in QWindow::event (this=0x2325010, ev=0x7fff7d378ed0) at kernel/qwindow.cpp:1930
      #24 0x00007fcec9c95a68 in QQuickWindow::event (this=0x2325010, e=0x7fff7d378ed0) at items/qquickwindow.cpp:1257
      #25 0x00007fcec223184e in QApplicationPrivate::notify_helper (this=0x1319710, receiver=0x2325010, e=0x7fff7d378ed0) at kernel/qapplication.cpp:3467
      #26 0x00007fcec222ee05 in QApplication::notify (this=0x7fff7d37b070, receiver=0x2325010, e=0x7fff7d378ed0) at kernel/qapplication.cpp:2888
      #27 0x00007fcec13fc90c in QCoreApplication::notifyInternal (this=0x7fff7d37b070, receiver=0x2325010, event=0x7fff7d378ed0) at kernel/qcoreapplication.cpp:878
      #28 0x00007fcec1a01623 in QCoreApplication::sendEvent (receiver=0x2325010, event=0x7fff7d378ed0) at ../../include/QtCore/../../src/corelib/kernel/qcoreapplication.h:232
      #29 0x00007fcec1a07501 in QWindow::setVisible (this=0x2325010, visible=false) at kernel/qwindow.cpp:451

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            sletta Gunnar Sletta
            Reporter:
            mgraesslin Martin Gräßlin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes