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

QQmlApplicationEngine.load() still occasionally fails silently



    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.9.3, 5.10.0, 5.9.4, 5.9.5, 5.10.1, 5.11.0
    • Fix Version/s: None
    • Labels:
    • Environment:
      windows 7 x64, ubuntu 16.04 x64, android, Qt 5.9.1, 5.9.3, 5.9.4, 5.10, gcc 5.3 x32, gcc 4.9 arm32, gcc 7.2 x64


      Originally reported here:



      Later duplicated by:


      Which was supposedly fixed


      However, the failure still occurs. The difference is that now it is not every time but occasionally. As illustrated in the attached clip, it doesn't occur in version 5.9.1.


      5.9.1 - 9 runs, 9 succeeded, 0 failed

      5.9.3 - 22 runs, 15 succeeded, 7 failed


      The application fails to load up the QML stuff property about 1/3 of the time. There is no apparent pattern to it. The code or external data doesn't change in between runs. Using the same Creator version in one session, simply switching kits, indicating that the problem is not with Creator but with Qt 5.9.3


      Updated the report to reflect that the same behavior occurs under 5.10 as well. I am getting the same behavior running apps in windows, linux and android.


      The issue exists in 5.9.4 as well.


      Update: The issue continues to manifest in every version of Qt ever since 5.9.1, which is still the last to never manifest it.

      The latest changes to the QML engine in 5.11 did not affect it in any way.

      Meanwhile, I tried to mitigate it by repeatedly attempting to create the application while still in the current process:

        bool success = false;
        app = 0;
        s = 0;
        engine = 0;
        int c = 0;
        do {
          if (app) delete app;
          if (engine) delete engine;
          if (s) delete s;
          if (c > 20) return -1;
          app = new QGuiApplication(argc, argv);    
          qRegisterMetaType<Base *>();
          qmlRegisterUncreatableType<T>("Types", 1, 0, "T", QString());
          qmlRegisterType<Base>("Core", 1, 0, "Base");
          qmlRegisterType<List>("Core", 1, 0, "CList");
          qmlRegisterType<UI>("GUI", 1, 0, "UI");
          qmlRegisterType<OUI>("GUI", 1, 0, "OUI");
          qmlRegisterType<IDManager>("Core", 1, 0, "IDManager");
          qmlRegisterType<Data>("Core", 1, 0, "Data");
          qmlRegisterSingletonType<System>("Sys", 1, 0, "SY", getSys);
          qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/C_Icons.qml")), "Icon", 1, 0, "IC");
          qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/S_Settings.qml")), "Set", 1, 0, "SS");
          qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/C_Update.qml")), "Update", 1, 0, "UU");
          qmlRegisterSingletonType(QUrl(QStringLiteral("qrc:/C_Factory.qml")), "Fac", 1, 0, "FF");
          engine = new QQmlApplicationEngine;
          s = new System(engine);
          engine->setObjectOwnership(s, QQmlEngine::CppOwnership);
          success = s->property("success").toBool();
          qDebug() << ++c << success;    
        } while (!success);

      This basically sets a `success` property to true if the qml manages to load, so I can check immediately after the call to `load()`, and on failure attempt to set up and run things anew so that it hopefully kicks in.

      However, that doesn't seem to help either, the problem appears to manifest on a per process run basis, if the first attempt to load fails, so do all subsequent, and I've let it to try thousands of times.

      I also tried reordering the registration of singletons in every possible order, to no effect.

      I made a note that doing an engine object dump gives me:

      QQmlApplicationEngine:: // on failure
      QQmlApplicationEngine:: // on success

      Which may be relevant to pinpoint the problem.

      So I get the component and try to do some introspection to see what is going on in there:

            QQmlComponent * cmp = engine->findChild<QQmlComponent *>();
            if (cmp) {
              qDebug() << cmp->status() << cmp->progress() << cmp->errors().size() << cmp->errorString() << cmp->url();


      The output is respectively `QQmlComponent::Status(Loading) 1 0 "" QUrl("qrc:/main.qml")`

      It still says loading although progress is 1 (finished) with no errors.

      just in case the engine might not happen to load things in time (presuming there is some multithreading going in there), I gave it a half a second pause between loading each singleton and before and after loading the main qml file for the main thread. No effect, once it fails it keeps failing.


      As usual, `load()` fails in complete silence, there is no output in the console, no application window, no warnings or errors are emitted via the signals.


          Issue Links

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



              shausman Simon Hausmann
              dgo dgo
              2 Vote for this issue
              8 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes