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

WebEngineView, QRhi, <select>; no context menu, and a crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.9.0 RC
    • WebEngine
    • None
    • nvidia 3080, driver 550.78
      ubuntu 22.04
      6.9.0-rc1 libraries from online installer
    • Linux/X11

    Description

      Clicking on <select> does not yield a popup, in addition clicking a second time will segfault.

      In my case, I don't even want a popup to appear, but QML's onContextMenuRequested does not seem to get fired.

      reproduce:

      1. clone the rendercontrol_rhi example from 6.9.0-rc1
      2. apply patch (see below)
      3. press 'Crash me' 2 times in the GUI (it simulates a mouse click, first click it should hit onContextMenuRequested , 2nd click I don't expect a segfault)
      #0  0x00005555574aa0d8 in  ()
      #1  0x00007ffff13b9011 in QXcbWindow::handleNativeEvent(xcb_generic_event_t*) (this=<optimized out>, event=0x555556cc73b0) at /home/qt/work/qt/qtbase/src/plugins/platforms/xcb/qxcbwindow.cpp:1713
      #2  0x00007ffff137e80b in QXcbConnection::handleXcbEvent(xcb_generic_event_t*) (this=this@entry=0x5555555d0520, event=event@entry=0x555556cc73b0)
          at /home/qt/work/qt/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp:695
      #3  0x00007ffff137ef06 in QXcbConnection::processXcbEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x5555555d0520, flags=...) at /home/qt/work/qt/qtbase/src/plugins/platforms/xcb/qxcbconnection.cpp:1087
      #4  0x00007ffff139ed17 in xcbSourceDispatch(GSource*, GSourceFunc, gpointer) (source=<optimized out>) at /home/qt/work/qt/qtbase/src/plugins/platforms/xcb/qxcbeventdispatcher.cpp:55
      #5  0x00007ffff4b1bd3b in g_main_context_dispatch () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #6  0x00007ffff4b712b8 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #7  0x00007ffff4b193e3 in g_main_context_iteration () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
      #8  0x00007ffff5865e8e in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) (this=0x55555570ea20, flags=...) at /home/qt/work/qt/qtbase/src/corelib/kernel/qeventdispatcher_glib.cpp:399
      #9  0x00007ffff558cd0b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) (this=this@entry=0x7fffffffd420, flags=..., flags@entry=...) at /home/qt/work/qt/qtbase/src/corelib/global/qflags.h:77
      #10 0x00007ffff5588c9a in QCoreApplication::exec() () at /home/qt/work/qt/qtbase/src/corelib/global/qflags.h:77
      #11 0x00005555555641ff in main(int, char**) (argc=1, argv=0x7fffffffd818) at /home/foo/qtdeclarative/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp:661
      
      
      git clone https://code.qt.io/qt/qtdeclarative.git --depth 1 --branch v6.9.0-rc1
      git apply patch.diff
      
      commit 4392f36f667c0ce85d3c2664a6de940daf33382f
      Author: Foo <foo@foo.com>
      Date:   Fri Mar 21 19:15:54 2025 +0200
      
          Crash me
      
      diff --git a/examples/quick/rendercontrol/rendercontrol_rhi/CMakeLists.txt b/examples/quick/rendercontrol/rendercontrol_rhi/CMakeLists.txt
      index be70e02d..807a3be5 100644
      --- a/examples/quick/rendercontrol/rendercontrol_rhi/CMakeLists.txt
      +++ b/examples/quick/rendercontrol/rendercontrol_rhi/CMakeLists.txt
      @@ -4,9 +4,9 @@
       cmake_minimum_required(VERSION 3.16)
       project(rendercontrol_rhi LANGUAGES CXX)
       
      -find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Widgets)
      +find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Widgets WebEngineQuick)
       
      -qt_standard_project_setup(REQUIRES 6.8)
      +qt_standard_project_setup(REQUIRES 6.9)
       
       qt_add_executable(rendercontrol_rhi WIN32 MACOSX_BUNDLE
           main.cpp
      @@ -17,6 +17,8 @@ target_link_libraries(rendercontrol_rhi PRIVATE
           Qt6::GuiPrivate
           Qt6::Quick
           Qt6::Widgets
      +    Qt6::WebEngineQuick
      +    Qt6::WebEngineCore
       )
       
       qt_add_qml_module(rendercontrol_rhi
      @@ -25,6 +27,8 @@ qt_add_qml_module(rendercontrol_rhi
               "demo.qml"
           RESOURCE_PREFIX
               "/"
      +    RESOURCES
      +        index.html
           NO_RESOURCE_TARGET_PATH
       )
       
      diff --git a/examples/quick/rendercontrol/rendercontrol_rhi/demo.qml b/examples/quick/rendercontrol/rendercontrol_rhi/demo.qml
      index 707d9cb3..c80b4d49 100644
      --- a/examples/quick/rendercontrol/rendercontrol_rhi/demo.qml
      +++ b/examples/quick/rendercontrol/rendercontrol_rhi/demo.qml
      @@ -2,155 +2,25 @@
       // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
       
       import QtQuick
      -import QtQuick.Particles
      +import QtWebEngine
       
       Rectangle {
           id: root
       
      -    gradient: Gradient {
      -        GradientStop { position: 0; color: "steelblue" }
      -        GradientStop { position: 1; color: "black" }
      -    }
      -
      -    Text {
      -        anchors.centerIn: parent
      -        text: "Qt Quick in a texture"
      -        font.pointSize: 40
      -        color: "white"
      -
      -        SequentialAnimation on rotation {
      -            PauseAnimation { duration: 2500 }
      -            NumberAnimation { from: 0; to: 360; duration: 5000; easing.type: Easing.InOutCubic }
      -            loops: Animation.Infinite
      -        }
      -    }
      -
      -    ParticleSystem {
      -        id: particles
      +    WebEngineView {
      +        id: webView
               anchors.fill: parent
      +        url: "qrc:///index.html"
      +        focus: true
      +        backgroundColor: "transparent"
       
      -        ImageParticle {
      -            id: smoke
      -            system: particles
      -            anchors.fill: parent
      -            groups: ["A", "B"]
      -            source: "qrc:///particleresources/glowdot.png"
      -            colorVariation: 0
      -            color: "#00111111"
      -        }
      -        ImageParticle {
      -            id: flame
      -            anchors.fill: parent
      -            system: particles
      -            groups: ["C", "D"]
      -            source: "qrc:///particleresources/glowdot.png"
      -            colorVariation: 0.1
      -            color: "#00ff400f"
      -        }
      -
      -        Emitter {
      -            id: fire
      -            system: particles
      -            group: "C"
      -
      -            y: parent.height
      -            width: parent.width
      -
      -            emitRate: 350
      -            lifeSpan: 3500
      -
      -            acceleration: PointDirection { y: -17; xVariation: 3 }
      -            velocity: PointDirection {xVariation: 3}
      -
      -            size: 24
      -            sizeVariation: 8
      -            endSize: 4
      -        }
      -
      -        TrailEmitter {
      -            id: fireSmoke
      -            group: "B"
      -            system: particles
      -            follow: "C"
      -            width: root.width
      -            height: root.height - 68
      -
      -            emitRatePerParticle: 1
      -            lifeSpan: 2000
      -
      -            velocity: PointDirection {y:-17*6; yVariation: -17; xVariation: 3}
      -            acceleration: PointDirection {xVariation: 3}
      -
      -            size: 36
      -            sizeVariation: 8
      -            endSize: 16
      +        onContextMenuRequested: function(request) {  // does not actually run for <select> ?
      +            request.accepted = true;
      +            console.log("context menu stopped");
               }
       
      -        TrailEmitter {
      -            id: fireballFlame
      -            anchors.fill: parent
      -            system: particles
      -            group: "D"
      -            follow: "E"
      -
      -            emitRatePerParticle: 120
      -            lifeSpan: 180
      -            emitWidth: TrailEmitter.ParticleSize
      -            emitHeight: TrailEmitter.ParticleSize
      -            emitShape: EllipseShape{}
      -
      -            size: 16
      -            sizeVariation: 4
      -            endSize: 4
      -        }
      -
      -        TrailEmitter {
      -            id: fireballSmoke
      -            anchors.fill: parent
      -            system: particles
      -            group: "A"
      -            follow: "E"
      -
      -            emitRatePerParticle: 128
      -            lifeSpan: 2400
      -            emitWidth: TrailEmitter.ParticleSize
      -            emitHeight: TrailEmitter.ParticleSize
      -            emitShape: EllipseShape{}
      -
      -            velocity: PointDirection {yVariation: 16; xVariation: 16}
      -            acceleration: PointDirection {y: -16}
      -
      -            size: 24
      -            sizeVariation: 8
      -            endSize: 8
      -        }
      -
      -        Emitter {
      -            id: balls
      -            system: particles
      -            group: "E"
      -
      -            y: parent.height
      -            width: parent.width
      -
      -            emitRate: 2
      -            lifeSpan: 7000
      -
      -            velocity: PointDirection {y:-17*4*2; xVariation: 6*6}
      -            acceleration: PointDirection {y: 17*2; xVariation: 6*6}
      -
      -            size: 8
      -            sizeVariation: 4
      -        }
      -
      -        Turbulence { //A bit of turbulence makes the smoke look better
      -            anchors.fill: parent
      -            groups: ["A","B"]
      -            strength: 32
      -            system: particles
      +        onJavaScriptConsoleMessage: function(level, message, lineNumber, sourceID) {
      +            console.log(message);
               }
           }
      -
      -    onWidthChanged: particles.reset()
      -    onHeightChanged: particles.reset()
       }
      diff --git a/examples/quick/rendercontrol/rendercontrol_rhi/index.html b/examples/quick/rendercontrol/rendercontrol_rhi/index.html
      new file mode 100644
      index 00000000..b5adb73a
      --- /dev/null
      +++ b/examples/quick/rendercontrol/rendercontrol_rhi/index.html
      @@ -0,0 +1,20 @@
      +<select style="width:100%;height:100%;">
      +  <option value="volvo">Volvo</option>
      +  <option value="saab">Saab</option>
      +  <option value="mercedes">Mercedes</option>
      +  <option value="audi">Audi</option>
      +</select>
      +
      +<script>
      +  document.addEventListener('mousedown', (event) => {
      +    console.log(`left mouse button down at X: ${event.clientX}, Y: ${event.clientY}`);
      +  });
      +
      +  document.addEventListener('mouseup', (event) => {
      +    console.log(`Mouse button released at X: ${event.clientX}, Y: ${event.clientY}`);
      +  });
      +
      +  document.addEventListener('click', (event) => {
      +    console.log(`Click detected at X: ${event.clientX}, Y: ${event.clientY}`);
      +  });
      +</script>
      \ No newline at end of file
      diff --git a/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp b/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp
      index 6b66d76e..96a21c71 100644
      --- a/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp
      +++ b/examples/quick/rendercontrol/rendercontrol_rhi/main.cpp
      @@ -8,6 +8,7 @@
       #include <QMenuBar>
       #include <QStatusBar>
       #include <QFileDialog>
      +#include <QTimer>
       #include <QMessageBox>
       #include <QLabel>
       #include <QScrollArea>
      @@ -144,6 +145,29 @@ MainWindow::MainWindow()
           });
           controlLayout->addWidget(btnMulti);
       
      +    QPushButton *btnCrash = new QPushButton(tr("Crash me"));
      +    QObject::connect(btnCrash, &QPushButton::clicked, btn, [this] {
      +        QMetaObject::invokeMethod(this, [=] {
      +            constexpr auto mouse_pos = QPointF(100, 100);
      +            constexpr Qt::MouseButton mouse_btn = Qt::LeftButton;
      +            constexpr QEvent::Type mouse_press = QEvent::MouseButtonPress;
      +            constexpr QEvent::Type mouse_release = QEvent::MouseButtonRelease;
      +
      +            // left click
      +            QMouseEvent mouseEvent(mouse_press, mouse_pos, mouse_pos, mouse_btn, mouse_btn, Qt::NoModifier);
      +            QCoreApplication::sendEvent(m_scene.get(), &mouseEvent);
      +
      +            // left release
      +            QTimer::singleShot(50, this, [this, mouse_btn, mouse_release, mouse_pos]() {
      +                QMouseEvent mouseEvent2(mouse_release, mouse_pos, mouse_pos, mouse_btn, mouse_btn, Qt::NoModifier);
      +
      +                QCoreApplication::sendEvent(m_scene.get(), &mouseEvent2);
      +            });
      +
      +        }, Qt::QueuedConnection);
      +    });
      +    controlLayout->addWidget(btnCrash);
      +
       //! [anim-slider]
           QSlider *animSlider = new QSlider;
           animSlider->setOrientation(Qt::Horizontal);
      

      Attachments

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

        Activity

          People

            qt_webengine_team Qt WebEngine Team
            sfer Robert Boon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes