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

Incremental QML gc deletes context property

    XMLWordPrintable

Details

    • d148d8d78 (dev), fbdbed919 (6.8), b34fca349 (6.8.1)

    Description

      https://bugs.kde.org/show_bug.cgi?id=494804 appears to be a regression in Qt 6.8.0:
      SDDM creates a QQuickView for each screen (with the default constructor, i.e. every instance has its own QQmlEngine) and adds some context properties. One of them is a simple QObject derived proxy object to call back into SDDM:

      void GreeterApp::addViewForScreen(QScreen *screen) {
          QQuickView *view = new QQuickView()
          ...
          // m_proxy was created earlier on startup, it's QObject derived without parent.
          view->rootContext()->setContextProperty(QStringLiteral("sddm"), m_proxy);
          ...
          // show
          qDebug() << "Adding view for" << screen->name() << screen->geometry();
          view->showFullScreen();
      }
      

      However, that context property is suddenly not accessible anymore on all screens except one, resulting in error messages like

      Okt 19 17:49:30  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:221:25: Unable to assign [undefined] to bool
      Okt 19 17:49:30  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:215:25: Unable to assign [undefined] to bool
      Okt 19 17:49:30  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:209:25: Unable to assign [undefined] to bool
      ...
      Okt 19 17:49:32  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Login.qml:134:17: Unable to assign QString to QObject*
      Okt 19 17:49:32  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:348:25: Unable to assign [undefined] to bool
      Okt 19 17:49:32  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:354:25: Unable to assign [undefined] to bool
      Okt 19 17:49:32  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:360:25: Unable to assign [undefined] to bool
      ...
      Okt 19 17:49:50  sddm-greeter-qt6[850]: file:///usr/share/sddm/themes/breeze/Main.qml:339: TypeError: Property 'login' of object Loader is not a function
      

      Apparently sddm is suddenly a QString or Loader on some views?

      The issue disappears when using QV4_MM_AGGRESSIVE_GC=1 QV4_GC_TIMELIMIT=0, which points to the incremental GC being the issue.

      I added some logging to qv4mm.cpp and see that callDestroyObject does indeed try to destroy the context property:

              // we need to call destroyObject on qobjectwrappers now, so that they can emit the destroyed
              // signal before we start sweeping the heap
              if (QObjectWrapper *qobjectWrapper = m->as<QObjectWrapper>()) {
                  if(qobjectWrapper->object())
                      DEBUG << "Destroying weak value object" << qobjectWrapper->object() << QQmlEngine::objectOwnership(qobjectWrapper->object());
                  qobjectWrapper->destroyObject(/*lastSweep =*/false);
              }
      
      Okt 31 16:27:51 fvogt-thinkpad sddm-greeter-qt6[110315]: MM: Destroying weak value object SDDM::GreeterProxy(0x5578658fa320) 0
      Okt 31 16:27:51 fvogt-thinkpad sddm-greeter-qt6[110315]: MM: Destroying weak value object SDDM::GreeterProxy(0x5578658fa320) 0
      Okt 31 16:27:51 fvogt-thinkpad sddm-greeter-qt6[110315]: MM: Destroying weak value object QQuickMouseEvent(0x557866873408) 0
      

      It's destroyed twice, which matches that two of the three QQuickView s are broken.

      Using a single QQmlEngine shared between all QQuickView s also avoids the issue.

      My guess is that either the incremental GC is confused by QObjects being used in multiple engines. Maybe the incremental runs affect each other (one engine clearing the marks set by another? That should break more violently though) or the incremental GC has issues with tainted objects?

      Unfortunately I'm unable to reproduce the issue outside of SDDM, so I can't provide some minimal reproducer
      I can try out patches easily though.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-130767
          # Subject Branch Project Status CR V

          Activity

            People

              olivier.decanniere Olivier De Cannière
              vogtinator Fabian Vogt
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes