QML Dynamically create component too slow
econsysqtdev last edited by
I'm working on a project involving a complex designs. We've designed the UI pages using Qt Quick.
I am creating a QML components using Qt.CreateComponent(). There is a setup page which has multiple tabs. This component contains a tabview.
Each tab is a separate QML file (Component). In the Desktop (Ubuntu 64 bit, 4 GB RAM) first time it takes around 250 ms to create the component. Subsequently the time reduces to around ~100 ms. In the target board it takes 3072 ms and subsequently reduces to ~1200 ms.
I'm creating the QML components dynamically. I create the rootItem in main.cpp and the other screens from QML using Qt.CreateComponent(). I'm always destroying and creating the component.
From my initial investigation, I found out that the reason behind this could be JIT (Just In Time Compilation).
I would like to understand if my assumption of JIT is correct.
If there is any other reason behind this, can anyone can tell me the reason why there is a time difference in creating between the first time and the next.
Any help is greatly appreciated.
Thanks & Regards,
This may sound weird, but try to run it under QML debugger/ profiler. Qt.createComponent() works faster then :D
If you suspect JIT, it can be turned off in Qt config (when you compile Qt).
Otherwise, I would suggest trying to pinpoint which parts of your code are the slowest (using QML profiler) and focus on those bottlenecks first. Then you can also investigate if it would not be better to start loading tabs in background after application starts - user will be occupied with tab 1, but in background engine will be loading tab 2, tab 3 etc.
You can also consider using QML compiler to have ready-made bytecode instead of loading and parsing QML code at runtime.