Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.2.4, 6.3.2, 6.4.3, 6.5.0 RC
-
None
-
-
74a4f9cb0 (dev), 8a805c1fd (6.5)
Description
I noticed significantly slower startup with my application built against Qt 6 compared to Qt 5. After some profiling, the increased startup time turned out to be related to loading of theme icons through QIcon::fromTheme. Previously (as of Qt 5), when an icon could not be found, it would anyway cache the result (a null icon) and subsequent calls to QIcon::fromTheme would return instantly. Since Qt 6, the function no longer caches failed icon lookups so each QIcon::fromTheme call again searches for the icon in all directories.
This, combined with the fact that the default icon theme "Adwaita" does not provide any of the icons searched for by my application (since it only provides "symbolic" version), causes the icon lookups to take about half a second more during application startup.
The caching of failed lookups was removed in https://codereview.qt-project.org/c/qt/qtbase/+/343396 and https://codereview.qt-project.org/c/qt/qtbase/+/419489. I personally think there has to be a better workaround for this, but I'm not sure about the best approach.
I've attached a small example project to demonstrate the issue. Note that it will be quite fast when the theme does have the icons, but very slow when it doesn't, like for GNOME's Adwaita theme.
Attachments
For Gerrit Dashboard: QTBUG-112257 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
471070,11 | Cache null icons and remove them upon system icon theme change | dev | qt/qtbase | Status: MERGED | +2 | 0 |
471462,2 | Cache null icons and remove them upon system icon theme change | 6.5 | qt/qtbase | Status: MERGED | +2 | 0 |
612876,4 | GUI: Add API to clear theme icon cache | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |