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. The cost of plugin scans
Forum Updated to NodeBB v4.3 + New Features

The cost of plugin scans

Scheduled Pinned Locked Moved Solved Mobile and Embedded
13 Posts 3 Posters 840 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    In this case I would say that the embedded system configuration is wrong. A normal Qt installation has the plugins stored in a specific path following a standard structure. The fact in yours the plugins have been put beside other libraries shows that something went wrong at some point in that regard.

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

    E 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      In this case I would say that the embedded system configuration is wrong. A normal Qt installation has the plugins stored in a specific path following a standard structure. The fact in yours the plugins have been put beside other libraries shows that something went wrong at some point in that regard.

      E Offline
      E Offline
      elahav
      wrote on last edited by
      #3

      @SGaist Thanks for the response. Sure, I can (and did) move the plugins to another location, but:

      1. How is someone building a system supposed to know that?
      2. All files in the directory where the executable resides still get scanned. I can have a 10GB database next to my executable, which will then be opened and mapped. Or I can have a thousand image files for the UI.

      So, if I am not missing an option to configure Qt differently, I think it is misbehaving.

      --Elad

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

        Not knowing how your custom system is built I can't really point you to the best resources for that.

        1. By checking the Qt documentation (and possibly also what other projects like yocto do)
        2. Is there some qt.conf file in your system ?

        Unless some customization is done, Qt will only scan the appropriate folders that are created when you install it.

        That said, do you have custom plugins for your application ?

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

        E 1 Reply Last reply
        0
        • SGaistS SGaist

          Not knowing how your custom system is built I can't really point you to the best resources for that.

          1. By checking the Qt documentation (and possibly also what other projects like yocto do)
          2. Is there some qt.conf file in your system ?

          Unless some customization is done, Qt will only scan the appropriate folders that are created when you install it.

          That said, do you have custom plugins for your application ?

          E Offline
          E Offline
          elahav
          wrote on last edited by
          #5

          No, only one plugin (the platform plugin), which is shared among all Qt applications.
          The point I am trying to make (and perhaps belongs in a bug report) is that opening and mapping all files, even in a known directory, is bad practice in general, but especially on an embedded system. There has to be a better way to let Qt know which are the plugins of interest (e.g., using a manifest file, or just a naming convention).

          --Elad

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

            I understand your issue.

            To the best of my knowledge there is none currently. If memory serves well the mapping is used to get the plugin metadata in order to load the ones requested.

            From a deployment point of view, what I would do (and have done in the past) is to customize the cross-compiled version to use only what was needed and thus also deploy only what was required. This minimized the footprint of Qt as well as the application.

            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
            • hskoglundH Online
              hskoglundH Online
              hskoglund
              wrote on last edited by
              #7

              Hi, one other possibility is if you can build a static version of Qt and build your app with that. Then all plugins are placed together with your code in the same .exe/.elf file.
              That executable file will be bigger, say around 20 - 40 MB, but no file mappings/scans are needed for the plugins :-)

              E 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Hi, one other possibility is if you can build a static version of Qt and build your app with that. Then all plugins are placed together with your code in the same .exe/.elf file.
                That executable file will be bigger, say around 20 - 40 MB, but no file mappings/scans are needed for the plugins :-)

                E Offline
                E Offline
                elahav
                wrote on last edited by
                #8

                @hskoglund Sure, but I have many Qt apps (in fact a whole desktop system of Qt apps...). Some of these use QtWebkitWidgets, which is not a small library.

                I can easily hack QFactoryLoader() to consider only files with a given name prefix/suffix. I posted here just to know if there is an existing way of avoiding the scan and if anyone else has noticed the problem.

                --Elad

                1 Reply Last reply
                0
                • hskoglundH Online
                  hskoglundH Online
                  hskoglund
                  wrote on last edited by
                  #9

                  And I assume you also have tried forcing/resetting the scan of plugins to a specific folder by using QCoreApplication::setLibraryPaths just before your QApplication constructor call?

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    elahav
                    wrote on last edited by
                    #10

                    Good idea, but it doesn't help.

                    int main(int argc, char *argv[])
                    {
                        QCoreApplication::setLibraryPaths(QStringList() << "/system/lib/plugins");
                    
                        QApplication app(argc, argv);
                        qDebug() << app.libraryPaths();
                    
                    

                    produces

                    ("/system/lib/qt", "/system/lib/plugins", "/system/opt/swmlogin")
                    

                    The path from QT_QPA_PLATFORM_PLUGIN_PATH is still there but, more importantly, so is the path of the executable. The latter is mentioned in the documentation of setLibraryPaths() as still being searched. Not to mention having to change the code of every application I use is not a viable solution.

                    Anyway, I'll create a bug report at least to provide an option to suppress/restrict scanning.

                    --Elad

                    1 Reply Last reply
                    0
                    • hskoglundH Online
                      hskoglundH Online
                      hskoglund
                      wrote on last edited by
                      #11

                      Hi, forgot one more option: create a qt.conf file next to your executable, with something like this inside:

                      [Paths]
                      Prefix=/system/lib
                      Plugins=/system/opt/swmlogin
                      

                      i..e set Plugins to the path of your executable's folder, then Qt will look for the platforms subdirectory in that folder.
                      (I think Qt's factoryloader does a deduplication of the entries so that it will only scan the folder once)
                      And also no modification of source code needed :-)

                      1 Reply Last reply
                      0
                      • E Offline
                        E Offline
                        elahav
                        wrote on last edited by
                        #12

                        Hmm... qt.conf seems to have no effect, Strange.

                        By the way, it looks like Windows only scans for files with the suffix .dll and Android only scans for files starting with libplugins_. From QFactoryLoader::update():

                                QStringList plugins = QDir(path).entryList(
                        #if defined(Q_OS_WIN)
                                            QStringList(QStringLiteral("*.dll")),
                        #elif defined(Q_OS_ANDROID)
                                            QStringList(QLatin1String("libplugins_%1_*.so").arg(d->suffix)),
                        #endif
                                            QDir::Files);
                        
                        1 Reply Last reply
                        0
                        • E Offline
                          E Offline
                          elahav
                          wrote on last edited by
                          #13

                          I rearranged things on the system:

                          1. Dropped QT_QPA_PLATFORM_PLUGIN_PATH
                          2. Set QT_PLUGIN_PATH to /system/lib/qt/plugins
                          3. Created a folder called platforms under the plugin path and moved the platform plugin there

                          Qt no longer maps any file other than the platform plugin, which is what I wanted from the start. I still don't understand the scan logic, but at least this problem is solved.

                          Thanks,
                          --Elad

                          1 Reply Last reply
                          2

                          • Login

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