After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 734651 - Resizing gtk3-iconbrowser is super slow
Resizing gtk3-iconbrowser is super slow
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: .General
3.13.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2014-08-12 10:33 UTC by Alexander Larsson
Modified: 2014-08-12 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GtkIconHelper: Short circuit _gtk_icon_helper_get_size in some cases (6.48 KB, patch)
2014-08-12 10:38 UTC, Alexander Larsson
committed Details | Review

Description Alexander Larsson 2014-08-12 10:33:23 UTC
When showing a page with a lot of icons (for instance "Other") resizing the window is super slow. Especially when showing symbolic icons.

The reason for this is obvious if you run "strace -eopen gtk3-icon-browser", it is constantly reloading/parsing the icon files from disk (visible always for symbolics and for pngs if you don't have image data in your icon cache).

This happens because during size request we're reusing a single GtkIconHelper
for all the icons in the icon view, asking for the preferred size. The _gtk_icon_helper_get_size() calls _gtk_icon_helper_ensure_surface() which loads the icon. For small pages the icon cache will keep all icons on the page in the cache, so this is fast. However, for larger pages (and since we never keep individual GtkIconInfos alive) we will constantly be trashing the cache and reloading the icons when iterating over all icons during the size request.
Comment 1 Alexander Larsson 2014-08-12 10:38:05 UTC
Created attachment 283173 [details] [review]
GtkIconHelper: Short circuit _gtk_icon_helper_get_size in some cases

_gtk_icon_helper_get_size() is often used during size request and may
not necessary mean that the icon will be displayed immediately. In
many common cases we know the size without having to ensure a surface.
In many cases this means we can avoid loading an icon until needed, and
in the case of stateless IconHelpers such as GtkCellRendererPixbuf this
is very important as otherwise it will constantly be reloading icons
if the displayed set is larger than the in-memory icon cache.
Comment 2 Matthias Clasen 2014-08-12 12:21:43 UTC
Review of attachment 283173 [details] [review]:

this will not make my 'image scaling' branch easier (where I try to make GtkImage scale its content to fit), but I think the speedup is worth it.
Comment 3 Alexander Larsson 2014-08-12 13:48:04 UTC
Attachment 283173 [details] pushed as 928822f - GtkIconHelper: Short circuit _gtk_icon_helper_get_size in some cases