Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

App slow startup



  • Hi. My app has slow starup, about 45 seconds. I notice importing one of 284.5 kB Javascript file takes 30 seconds. I wonder why it takes a long time to import this Javascript into an QML? I also notice that my other 62.7 kB Javascript, takes under a second to import. Comparing these Javascript files, the fast JavaScript file has .pragma library and .import; whereas, the slow one does not have those. Could you suggest some ideas on how to further investigate or to resolve the issue?
    Thanks


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What do you have in that big file ? Do you need everything from it ?



  • Thank you, SGaist. In the big file, there are just a handful of functions. There is a giant function containing 5,000 line of codes ( don't ask me why since I have just given this project), and for startup, this is a real bottleneck function. This function is being called once upon startup. To verify, I comment out the caller, so that this method won't get invoked, and there is no improvement in startup time. Now if I literally remove the body of this giant method and return null, startup time is reduced to just 18 seconds. I want to refactor this function and move it to c++ side; unfortunately, this function is quite complicate. Thus, refactor would be time consuming. So now. I am looking for suggestions.



  • Do you need that function really at start up? I am not sure if that works, but you could try to put the import statement in a own QML component that gets loaded asynchronously in a Loader.


Log in to reply