Qball's Weblog

IconView slow hell

Tags General  gmpc 

There was a post about a music client that showed all album covers in a huge list. I thought, lets try this in gmpc. I allready got a GtkTreeModel (GmpcMpdDataModel) that can show all info displayed there.

So after a few minutes of hacking up a plugin I had a GtkIconView showing me all the artists images + names. This however was so slow, it took around 5 minutes to display. It got a little better then I forced a fixed width on an item.

It looks like this. But still terrible slow. (and still took minutes)

So I read somewhere the the exo_icon_view (from xfce) is a lot faster.  Well it is somewhat faster, but looks like this.

Why are these things so slow? Well one of the reasons, every single image in the list is drawn. Independent from being visible or not.  In a gtktreeview, you can set fixed-height mode  to solve this issue. But there is no option todo this in *IconView.

So I spend a few minutes writing a quick icon view using a GtkTable + GmpcMetaImage. (this is an image you give an MpdSong and it will display the requested image, with some nice extras).

This was a huge improvement, but still slow. Because it tried to fetch cover art for all the 4400 artists in my (test) db. After fiddling with GmpcMetaImage I had it only fetch the cover/artist image when the actually image was visible to the user.

This reduced the time a lot, 12 seconds to display the whole list.  8 off these seconds where used to create the 4400 GmpcMetaImages. This turned out to be in the drawing of the default placeholder image. (queried via gtk_icon_theme_load_icon), removing this reduced the time to create 4400 GmpcMetaImage  to 400ms.

Now it takes around 4 seconds to display after I added it to the GtkTable. I assume this is gtk calculating the widths  of the columns etc. (I can’t tell them how large they will be, even if I know this).  But this is a huge improvement over the original GtkIconView. (looks like this currently). I wish I did not have to write my own stuff todo something this simple.

If I get the whole thing fast enough (and more usable) I might release a plugin that shows it like this.

More to come.

update: QT seems todo this like 100000000000000000x faster.