Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Crash when trying to show QQuickWidget within a QOpenGLWidget when using OpenGLRhi
QtWS25 Last Chance

Crash when trying to show QQuickWidget within a QOpenGLWidget when using OpenGLRhi

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
crashiosopenglopenglrhiqtquick
2 Posts 1 Posters 627 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hexo
    wrote on 31 May 2023, 19:24 last edited by
    #1

    Whenever I try to show a QQuickWidget while using a QOpenGLWidget, qt crashes with the following message:

    ASSERT: "texD->texture && texD->specified" in file /Users/qt/work/qt/qtbase/src/gui/rhi/qrhigles2.cpp, line 5462

    Which seems to be a reference to this line: https://github.com/qt/qtbase/blob/ea1af6b7ed972910c6e125f9946f1f03f7b0de45/src/gui/rhi/qrhigles2.cpp#L5555 .

    Here is a minimal code sample to reproduce the issue:

    #include <QApplication>
    #include <QOpenGLWidget>
    #include <QOpenGLFunctions>
    #include <QQuickWidget>
    
    
    class MyOpenGLWidget : public QOpenGLWidget {
    public:
    
        MyOpenGLWidget(QWidget* p=nullptr) : QOpenGLWidget(p){
    
            // if we move the contents of mousePressEvent here then there is no crash!
        }
    
        void mousePressEvent(QMouseEvent* mevent) {
            // this crashes!
            auto selector = new QQuickWidget(this);
            selector->show();
        }
    
        void paintGL() override {
            glClearColor(1, 0, 0, 1);
            glClear(GL_COLOR_BUFFER_BIT);
        }
    };
    
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
    
        MyOpenGLWidget widget;
        widget.show();
    
        return a.exec();
    }
    

    Some notes:

    • I am using Qt 6.5.0 on MacOS.
    • As shown in the code, if I move auto selector = new QQuickWidget(this);selector->show(); to the constructor instead of click event, then there is no crash and the widget is shown properly.
    • The crash only occurs when using QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
    • I have only observed the crash on x86_64 iOS simulator. When running on my m1 macbook the crash doesn't happen and the app works perfectly. (I don't have an iOS device so I can't test it on ios arm64 architecture)

    Any help would be greatly appreciated.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hexo
      wrote on 1 Jun 2023, 10:44 last edited by
      #2

      Also here is the stacktrace if it helps:

      0   ???                                      0x10a1029a8 ???
      1   <translation info unavailable>           0x10c7d5e24 ???
      2   libsystem_pthread.dylib                  0x115b91ee6 pthread_kill + 263
      3   libsystem_c.dylib                        0x114e06e58 abort + 130
      4   test5                                    0x104c96839 qAbort() + 9 (qglobal.cpp:161)
      5   test5                                    0x104c9b6b8 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) + 24 (qlogging.cpp:2048)
      6   test5                                    0x10510d7b6 QMessageLogger::fatal(char const*, ...) const + 246 (qlogging.cpp:934)
      7   test5                                    0x10510d08a qt_assert(char const*, char const*, int) + 74 (qassert.cpp:68)
      8   test5                                    0x1041c7e45 QGles2TextureRenderTarget::create() + 981 (qrhigles2.cpp:5462)
      9   test5                                    0x103580e82 QQuickWidget::createFramebufferObject() + 1890 (qquickwidget.cpp:1137)
      10  test5                                    0x103585ad1 QQuickWidget::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 225 (moc_qquickwidget.cpp:295)
      11  test5                                    0x104da0579 void doActivate<false>(QObject*, int, void**) + 2313 (qobject.cpp:4004)
      12  test5                                    0x104d9f039 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 121 (qobject.cpp:4052)
      13  test5                                    0x103607465 QQuickWindow::sceneGraphInitialized() + 37 (moc_qquickwindow.cpp:829)
      14  test5                                    0x10360665d QQuickWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 109 (moc_qquickwindow.cpp:570)
      15  test5                                    0x104da0579 void doActivate<false>(QObject*, int, void**) + 2313 (qobject.cpp:4004)
      16  test5                                    0x104d9f039 QMetaObject::activate(QObject*, QMetaObject const*, int, void**) + 121 (qobject.cpp:4052)
      17  test5                                    0x1036b52d2 QSGRenderContext::initialized() + 34 (moc_qsgcontext_p.cpp:289)
      18  test5                                    0x1036c7b67 QSGDefaultRenderContext::initialize(QSGRenderContext::InitParams const*) + 295 (qsgdefaultrendercontext.cpp:57)
      19  test5                                    0x1035f1a1a QQuickRenderControl::initialize() + 378 (qquickrendercontrol.cpp:309)
      20  test5                                    0x1035806d3 QQuickWidgetPrivate::initializeWithRhi() + 867 (qquickwidget.cpp:1058)
      21  test5                                    0x1035837aa QQuickWidget::resizeEvent(QResizeEvent*) + 474 (qquickwidget.cpp:1404)
      22  test5                                    0x1038782cb QWidget::event(QEvent*) + 2683 (qwidget.cpp:9076)
      23  test5                                    0x103584fb9 QQuickWidget::event(QEvent*) + 1321 (qquickwidget.cpp:1719)
      24  test5                                    0x1037ea0ba QApplicationPrivate::notify_helper(QObject*, QEvent*) + 458 (qapplication.cpp:3284)
      25  test5                                    0x1037ee456 QApplication::notify(QObject*, QEvent*) + 11974 (qapplication.cpp:3231)
      26  test5                                    0x104d2212a QCoreApplication::notifyInternal2(QObject*, QEvent*) + 282 (qcoreapplication.cpp:1115)
      27  test5                                    0x104d22df3 QCoreApplication::sendEvent(QObject*, QEvent*) + 131 (qcoreapplication.cpp:1533)
      28  test5                                    0x10386f721 QWidgetPrivate::sendPendingMoveAndResizeEvents(bool, bool) + 353 (qwidget.cpp:7944)
      29  test5                                    0x103875ff0 QWidgetPrivate::show_helper() + 64 (qwidget.cpp:7995)
      30  test5                                    0x10387707f QWidgetPrivate::setVisible(bool) + 943 (qwidget.cpp:8344)
      31  test5                                    0x103876cc0 QWidget::setVisible(bool) + 144 (qwidget.cpp:8276)
      32  test5                                    0x10386871e QWidget::showMaximized() + 126 (qwidget.cpp:3057)
      33  test5                                    0x103875e94 QWidget::show() + 100 (qwidget.cpp:7900)
      34  test5                                    0x102e70702 MyOpenGLWidget::mousePressEvent(QMouseEvent*) + 82 (main.cpp:16)
      35  test5                                    0x103877a73 QWidget::event(QEvent*) + 547 (qwidget.cpp:8902)
      36  test5                                    0x1037ac198 QOpenGLWidget::event(QEvent*) + 712 (qopenglwidget.cpp:1698)
      37  test5                                    0x1037ea0ba QApplicationPrivate::notify_helper(QObject*, QEvent*) + 458 (qapplication.cpp:3284)
      38  test5                                    0x1037ec11c QApplication::notify(QObject*, QEvent*) + 2956 (qapplication.cpp:2772)
      39  test5                                    0x104d2212a QCoreApplication::notifyInternal2(QObject*, QEvent*) + 282 (qcoreapplication.cpp:1115)
      40  test5                                    0x104d22e83 QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) + 131 (qcoreapplication.cpp:1547)
      41  test5                                    0x1037eabd0 QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool, bool) + 1216 (qapplication.cpp:2356)
      42  test5                                    0x1038a44a5 QWidgetWindow::handleMouseEvent(QMouseEvent*) + 4485 (qwidgetwindow.cpp:623)
      43  test5                                    0x1038a2849 QWidgetWindow::event(QEvent*) + 361 (qwidgetwindow.cpp:241)
      44  test5                                    0x1037ea0ba QApplicationPrivate::notify_helper(QObject*, QEvent*) + 458 (qapplication.cpp:3284)
      45  test5                                    0x1037ee474 QApplication::notify(QObject*, QEvent*) + 12004 (qapplication.cpp:3235)
      46  test5                                    0x104d2212a QCoreApplication::notifyInternal2(QObject*, QEvent*) + 282 (qcoreapplication.cpp:1115)
      47  test5                                    0x104d22e83 QCoreApplication::sendSpontaneousEvent(QObject*, QEvent*) + 131 (qcoreapplication.cpp:1547)
      48  test5                                    0x103e0f2b0 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2384 (qguiapplication.cpp:2277)
      49  test5                                    0x103e0ec51 QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 753 (qguiapplication.cpp:2187)
      50  test5                                    0x103e110b4 QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent*) + 5412 (qguiapplication.cpp:3081)
      51  test5                                    0x103e0e2de QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 110 (qguiapplication.cpp:2035)
      52  test5                                    0x103e74a5e QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 190 (qwindowsysteminterface.cpp:1094)
      53  test5                                    0x102e7af11 QIOSEventDispatcher::processPostedEvents() + 545 (qioseventdispatcher.mm:443)
      54  test5                                    0x104f9bf3b RunLoopSource<QEventDispatcherCoreFoundation>::process(void*) + 107 (qeventdispatcher_cf_p.h:111)
      55  CoreFoundation                           0x113e56b8f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
      56  CoreFoundation                           0x113e56ad1 __CFRunLoopDoSource0 + 157
      57  CoreFoundation                           0x113e5632b __CFRunLoopDoSources0 + 311
      58  CoreFoundation                           0x113e509ba __CFRunLoopRun + 889
      59  CoreFoundation                           0x113e50264 CFRunLoopRunSpecific + 560
      60  GraphicsServices                         0x1225e324e GSEventRunModal + 139
      61  UIKitCore                                0x13abc47bf -[UIApplication _run] + 994
      62  UIKitCore                                0x13abc95de UIApplicationMain + 123
      63  test5                                    0x102e79161 qt_main_wrapper + 705 (qioseventdispatcher.mm:206)
      64  dyld_sim                                 0x112701384 start_sim + 10
      65  dyld                                     0x20a3db41f start + 1903
      
      1 Reply Last reply
      0

      2/2

      1 Jun 2023, 10:44

      • Login

      • Login or register to search.
      2 out of 2
      • First post
        2/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved