Unsolved QML apps take long time to load
-
Hi. I have a QML app and when deploying release builds it takes a long time to start up. I've tried it on a bunch of machines and VMs and it seems to range between 3 and 10 seconds for anything to appear depending on the machine.
I tried precompiling all my QML using the CMAKE code specified by Qt documentation but the launch time appears to remain unchanged.
This is the CMAKE code I'm using for non-precompiled qml:
find_package(Qt5Core) find_package(Qt5Network) find_package(Qt5Gui) find_package(Qt5Qml) find_package(Qt5Quick) find_package(Qt5QuickControls2) find_package(Qt5QuickCompiler) set(HEADERS ... ... ... ) set(SOURCES main.cpp ... ... ... qml.qrc ) add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS}) target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Gui Qt5::Qml Qt5::Quick Qt5::QuickControls2 )
and this is the CMAKE code I'm using to precompile the QML:
find_package(Qt5Core) find_package(Qt5Network) find_package(Qt5Gui) find_package(Qt5Qml) find_package(Qt5Quick) find_package(Qt5QuickControls2) find_package(Qt5QuickCompiler) set(HEADERS ... ... ... ) set(SOURCES main.cpp ... ... ... ) qtquick_compiler_add_resources(RESOURCES qml.qrc) add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${RESOURCES} ${HEADERS}) target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network Qt5::Gui Qt5::Qml Qt5::Quick Qt5::QuickControls2 )
I'm led to believe by Qt documentation (https://doc.qt.io/qt-5/qtquick-deployment.html#ahead-of-time-compilation) that the second should result in a faster to load QML application when deployed but this doesn't appear to be the case.
On my current machine (pretty beefy threadripper 2920X with a GTX 1070) both the precompiled and non-precompiled versions of the app are taking around 4 seconds to display a Window from the point of double clicking the exe, and this is a pretty small application.
Is there anything I can do to speed up that initial load time? (Qt 5.12.3)