Some apps can trigger GTK's "icon theme scanner" twice
Hi!
I'm not sure if the title is worded correctly, plus I'm not really a C programmer...
But after noticing how some GTK 4 apps were taking a significant amount of time to launch on my computer, I tried investigating the reason why, especially because this is not an issue with GTK 3 apps.
After some shameful printf debugging, I came to the (hopefully right) conclusion that some apps built with libadwaita are triggering GTK's "icon theme scanner" twice (instead of just once), causing a visible slowdown in application startup.
This is especially noticeable when:
- a) a large icon theme is active (e.g. Papirus);
- b) you have a slow storage device (e.g. HDD or SD card).
To reproduce this issue, just build and run the demo app inside the demo
directory with GTK_DEBUG=icontheme
:
$ GTK_DEBUG=icontheme ./builddir/demo/adwaita-1-demo
Output: stderr-adwaita-1-demo.txt
As you can see from the output, GTK's icon scanner runs twice for the same icon theme. The slowdown is most likely caused due to GTK traversing all directories of the icon theme twice.
But, like I said, it's only some libadwaita apps that exhibit this behavior. For instance, this doesn't happen with the hello.c
example in examples/hello-world
:
GTK_DEBUG=icontheme ./builddir/examples/hello-world/hello
Output: stderr-hello.txt
Since I'm not a C programmer, I can't exactly pin-point to the root cause, so any help is appreciated.
Thank you!