GNOME Bugzilla – Bug 760381
Make cover art downloading async
Last modified: 2016-01-10 23:58:45 UTC
The current approach causes main thread stalls, leaving the UI barely responsive. This is most noticeable if you move aside all of ~/.cache/media-art and start gnome-music (NB, you may need the grilo-plugins patch in bug #760378, otherwise cover art won't be found). I'm attaching a patch that does all the operation asynchronous using GIO APIs, it will still feel somewhat slow (esp. scrolling), but the UI will at least stay responsive.
Created attachment 318610 [details] [review] albumArtCache: Use GIO async APIs to download cover art The previous approach of spawning a thread that made synchronous calls resulted on long main thread stalls because of the GIL, using GIO async APIs largely solves this problem. Now we download cover art files in several stages: 1) Open the input stream from the http(s) url we get from grilo 2) Open the output stream for the corresponding ./cache/album-art file 3) Splice these together and wait for the transfer to be complete 4) Try getting a pixbuf again All these stages are done asynchronously so the main thread GMainContext is still able to process events while cover art is being downloaded. Additionally, The final phase of attempting to load the pixbuf again is now performed by reusing the lookup() function, an additional argument has been added so we can bail out if it fails to load/find a pixbuf the second time again. Also, remove the thread queue, and the corresponding signal, this is now all unused.
Review of attachment 318610 [details] [review]: awesome Carlos!
Cheers! Pushed to master. Attachment 318610 [details] pushed as 9a045df - albumArtCache: Use GIO async APIs to download cover art