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

Crash when hiding QtQuick window with wayland/EGL

    XMLWordPrintable

Details

    • Linux/Wayland
    • b19b0fbaf775e8b8eda1e03c265a5393d618c6c0 (qt/qtwayland/dev) a3ee3b1ac6752cb1e1bf86f8ef972f7d410e1d50 (qt/tqtc-qtwayland/5.15) c0ef4aa9529453197245f2db36df1d6b064e8532 (qt/qtwayland/6.1)

    Description

      Hi,

      When running the following snippet, the program will segfault as soon as the instantiated window is hidden by the timer:

      import QtQuick 2.15
      import QtQuick.Window 2.2
      
      Window {
          component TestPopup: Window {
              id: win
              visibility: Window.Windowed
              width: 150
              height: 150
              Rectangle {
                  anchors.centerIn: parent
                  width: 100
                  height: 100
                  color: "red"
                  RotationAnimation on rotation {
                      loops: Animation.Infinite
                      from: 0
                      to: 360
                  }
              }
              Timer {
                  running: true
                  repeat: true
                  interval: 500 + Math.random() * 500
                  onTriggered: {
                      if (win.visibility != Window.Hidden)
                          win.visibility = Window.Hidden;
                      else
                          win.visibility = Window.Windowed;
                  }
              }
          }
          TestPopup { color: "blue" }
      }
      

      I'm running the snippet with the following command:

      QT_QPA_PLATFORM=wayland-egl qml snippet.qml
      

      AFAIK this was working fine in Qt 5.9. What we see is that the platform window is destroyed after a call to setVisible(false), which triggers the destruction of the wl_egl_window and wl_surface. But the scenegraph thread is still using the window for rendering (ie calling swapBuffers), so the process crashes. I can reproduce this on both GNOME/wayland with up to date mesa drivers and also on embedded devices with proprietary drivers.

      I can reproduce the issue with both Qt 5.15 and Qt 6.0.

      Here's the stack trace with Qt6:

      0x00007ffff1534db0 in QtWayland::wl_surface::damage_buffer(int, int, int, int) () from /home/rawoul/Work/Qt/6.0.1/gcc_64/plugins/platforms/../../lib/libQt6WaylandClient.so.6
      (gdb) bt
      #0  0x00007ffff1534db0 in QtWayland::wl_surface::damage_buffer(int, int, int, int) () at /home/rawoul/Work/Qt/6.0.1/gcc_64/plugins/platforms/../../lib/libQt6WaylandClient.so.6
      #1  0x00007ffff1503a91 in QtWaylandClient::QWaylandAbstractDecoration::contentImage() () at /home/rawoul/Work/Qt/6.0.1/gcc_64/plugins/platforms/../../lib/libQt6WaylandClient.so.6
      #2  0x00007ffff1a21ad1 in  () at /home/rawoul/Work/Qt/6.0.1/gcc_64/plugins/platforms/libqwayland-egl.so
      #3  0x00007ffff6546bff in QOpenGLContext::swapBuffers(QSurface*) () at /home/rawoul/Work/Qt/6.0.1/gcc_64/bin/../lib/libQt6Gui.so.6
      #4  0x00007ffff656a451 in  () at /home/rawoul/Work/Qt/6.0.1/gcc_64/bin/../lib/libQt6Gui.so.6
      #5  0x00007ffff640eedd in QRhi::endFrame(QRhiSwapChain*, QFlags<QRhi::EndFrameFlag>) () at /home/rawoul/Work/Qt/6.0.1/gcc_64/bin/../lib/libQt6Gui.so.6
      #6  0x00007fffc615addb in  () at /home/rawoul/Work/Qt/6.0.1/gcc_64/qml/QtQuick/../../lib/libQt6Quick.so.6
      #7  0x00007fffc615c5f7 in  () at /home/rawoul/Work/Qt/6.0.1/gcc_64/qml/QtQuick/../../lib/libQt6Quick.so.6
      #8  0x00007ffff5addec6 in  () at /home/rawoul/Work/Qt/6.0.1/gcc_64/bin/../lib/libQt6Core.so.6
      #9  0x00007ffff5448590 in start_thread (arg=0x7fffc52db640) at pthread_create.c:463
      #10 0x00007ffff536e223 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
      

      Attachments

        Issue Links

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

          Activity

            People

              esabraha Eskil Abrahamsen Blomfeldt
              rawoul Arnaud Vrac
              Votes:
              0 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes