Unsolved Qt application startup time too long
-
Hello,
I have created an application Qt widget based on Qt 5.7.1 to use with beaglebone black on EGLFS.
While launching this app when calling first timeui->setupUi(this);
application takes as long as 3 seconds to complete this function.Which increases application startup time. Well there are 20 screen in my aplication which has resolution of 480x272 and using precompiled headers.
Passing below optimization in .pro fileQMAKE_CXXFLAGS_RELEASE *= -O3
How to reduce startup time.
Thanks
-
hi @jigarp,
precompiled headers don't matter.
3 seconds sounds long, are you sure it is only
setupUi()
taking so long?Can you test a minimal program? It should be instantly starting.
-
@jigarp said in Qt application startup time too long:
ui->setupUi(this);
As @aha_1980 said, 3 secs is long. What is that UI ? How many screens you have in that ? It is possible that you many objects/screens coming from designer. Please check that. If you can simple project, does it take some time ? Better to check that ?
-
Hello,
@aha_1980
Well i'm using elapsed timer to check timing.
it shows 1002292 nanoseconds nearly 1ms before function call &
2203569209 nanoseconds nearly 2203ms after function completed.This is application only for the first time ui->setupUi(this); function is called after that it is not taking much time.
@dheerendra
I have 20 screens all of that created using designer as per mentioned above. -
@jigarp Then you need to investigate, what in
ui->setupUi(this);
takes that long.The 20 screens should be no problem, or do you set up all 20 screens within this function? If yes, you should break that up into multiple functions.
For a fast start, you just need to show the mainwindow first.
This is application only for the first time ui->setupUi(this); function is called after that it is not taking much time.
Sounds like something big is loaded from flash memory - but as said, you need to investigate what exactly takes that long.
Can you run that app on your computer? That would make profiling more easy, I think.
-
Well I'm creating 1 main window & 2 dialog window before show.
Ex:-
Background Screen (QMainWindow) --> ui->setupUi(this); --> takes 2ms- Child 1 (QDialog) --> ui->setupUi(this); --> takes 3s
- Child 2 (QDialog) --> ui->setupUi(this); --> takes 2ms
All other screens are created after 100ms started after Child 2 creation
While debugging my application it show that icon.addFile taking time
Where i've created a pushbutton and showing icon on it using ui designer. -
@jigarp said in Qt application startup time too long:
While debugging my application it show that icon.addFile taking time
Can you elaborate on this?
- Which icon format is it?
- Which resolution?
- Are you loading the icon from disk or from a resource?
- Is your app fast if you remove the icon from the button?
Regards
-
Hello,
- Which icon format is it?
PNG - Which resolution?
210x65 - Are you loading the icon from disk or from a resource?
resource file - Is your app fast if you remove the icon from the button?
while i remove it,it takes time when next icon will be loading resolution is 24x24
Thanks
- Which icon format is it?
-
@jigarp So to conclude for now, it's the first
QIcon.addFile()
call that loads an icon from a resource, which takes very long? All additional load calls are fast?How big is your resource file?
-
@jigarp
That's not unusal, loading Images/Pixmaps into memory is one of the most expensive functions your gui will do, closely followed by setStyleSheet calls.I think, haven't used it myself yet, you can negate that effect somewhat by using a QPixmapCache and prioritising the start page of course.
[Edit aha_1980: Fixed typos]
-
@aha_1980 said in Qt application startup time too long:
How big is your resource file?
Well it is around 2.8 MB
-
Have you already seen this: https://stackoverflow.com/questions/36128342/how-to-handle-large-qt-resource-files-on-a-system-with-a-very-slow-storage ?
You should also read http://doc.qt.io/qt-5/resources.html esp. compression and external resources might help you to speed up loading.
-
Hi,
An additional point to take into account, some image formats are heavier to uncompress that others. Which one are you using ?