Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt application startup time too long
Forum Updated to NodeBB v4.3 + New Features

Qt application startup time too long

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
13 Posts 5 Posters 5.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J jigarp

    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 time

        ui->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 file

    QMAKE_CXXFLAGS_RELEASE *= -O3
    

    How to reduce startup time.

    Thanks

    aha_1980A Offline
    aha_1980A Offline
    aha_1980
    Lifetime Qt Champion
    wrote on last edited by aha_1980
    #2

    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.

    Qt has to stay free or it will die.

    1 Reply Last reply
    1
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #3

      @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 ?

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jigarp
        wrote on last edited by
        #4

        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.

        aha_1980A 1 Reply Last reply
        0
        • J jigarp

          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.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #5

          @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.

          Qt has to stay free or it will die.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jigarp
            wrote on last edited by jigarp
            #6

            @aha_1980

            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.

            aha_1980A 1 Reply Last reply
            0
            • J jigarp

              @aha_1980

              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.

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by aha_1980
              #7

              @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

              Qt has to stay free or it will die.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jigarp
                wrote on last edited by
                #8

                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

                aha_1980A J.HilkJ 2 Replies Last reply
                0
                • J jigarp

                  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

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by aha_1980
                  #9

                  @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?

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  0
                  • J jigarp

                    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

                    J.HilkJ Online
                    J.HilkJ Online
                    J.Hilk
                    Moderators
                    wrote on last edited by aha_1980
                    #10

                    @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]


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    3
                    • J Offline
                      J Offline
                      jigarp
                      wrote on last edited by
                      #11

                      @aha_1980 said in Qt application startup time too long:

                      How big is your resource file?

                      Well it is around 2.8 MB

                      aha_1980A 1 Reply Last reply
                      0
                      • J jigarp

                        @aha_1980 said in Qt application startup time too long:

                        How big is your resource file?

                        Well it is around 2.8 MB

                        aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on last edited by aha_1980
                        #12

                        @jigarp

                        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.

                        Qt has to stay free or it will die.

                        1 Reply Last reply
                        1
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          Hi,

                          An additional point to take into account, some image formats are heavier to uncompress that others. Which one are you using ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved