Lots of thumbnail requests with invalid size

Bug #1467743 reported by Michi Henning
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
High
Bill Filler
gallery-app (Ubuntu)
Fix Released
High
Arthur Mello
thumbnailer (Ubuntu)
Invalid
High
Unassigned

Bug Description

When using the gallery app, the thumbnailer gets loads of requests with QSize(-1,-1), for example, when opening the gallery app.

The problem with this is that the thumbnailer interprets this to mean "give me the largest size you can (limited to a 1920x1920 bounding box). That's very expensive, especially in terms of disk space, because that 1920 "thumbnail" ends up going into the cache, needlessly hogging space.

We are about to add a qWarning message to the QML side that reports invalid QSize requests. For now, we are going to retain the old behavior, but this will turn into an error soon.

The most effective way to use the thumbnailer is to simply ask for an image in the desired size, with neither width nor height of -1. The thumbnailer will efficiently produce a thumbnail for that. (We do lots of internal caching to avoid extracting or downloading a thumbnail unnecessarily.)

The thumbnailer may deliver a thumbnail that is smaller than what was asked for (because it never up-scales) so, if asked for a thumbnail of size 256, it's guaranteed not to be larger, but might be smaller (if the original image is smaller than what was asked for).

Could you please adjust the gallery app behavior to ask for specific, valid sizes only?

Running a tail -f on ~/.cache/upstart/dbus.log allows you to see the requests as they are made. Each request shows the size that was asked for.

Related branches

Changed in gallery-app:
importance: Undecided → High
Changed in thumbnailer (Ubuntu):
importance: Undecided → High
Revision history for this message
Michi Henning (michihenning) wrote :

It looks like this seriously affects the user experience too.

Take about 40-50 photos. Run gallery-app. Go to the photo roll.

Scroll up and down until all the thumbnails have been generated. (This loads up the cache.)

Run tail -f ~/.cache/upstart/dbus.log on the phone.

Now scroll up and down in the photo roll.

The trace shows that all the thumbnail requests are made with QSize(-1,-1). The thumbnailer delivers each thumbnail in around 1.5 msec. But the screen shows lots of spinners for quite some time. Presumably, that's happening because all the thumbnails are 1920 in size, but need to be scaled down to the size required on-screen. Asking for the thumbnails in the correct size would make things go considerably faster, I suspect.

tags: added: invalid-qsize
Revision history for this message
Sebastien Bacher (seb128) wrote :

Hey Arthur, I saw that you landed some changes recently [1] around thumbnailer use, could you check if that has to do with the issue described there?

[1] https://code.launchpad.net/~artmello/gallery-app/gallery-app-disable_gallery_photo_component/+merge/263818

affects: gallery-app → gallery-app (Ubuntu)
Changed in gallery-app (Ubuntu):
assignee: nobody → Arthur Mello (artmello)
Revision history for this message
Bill Filler (bfiller) wrote :

I'm not seeing any requests for -1 in dbus.log using thumbnailer from silo 10, but we have not changed the code in Photo Roll at all so not sure why the problem is not occuring.

@michi
Would you mind retesting with the latest rc-proposed image with silo 10 installed?

Revision history for this message
Michi Henning (michihenning) wrote :

We made a last-minute change to treat invalid QSize requests as 128x128, so the -1, -1 requests no longer show up in dubs.log.

However, if you look in ~.cache/upstart/application-click-com.ubuntu.gallery_gallery_2.9.1.1209.log, you'll see tons and tons of invalid QSize requests.

We are planning on returning an error for these soonish, so it would be good to pass the correct QSize for each thumbnail.

Revision history for this message
Bill Filler (bfiller) wrote :

confirmed, seeing the invalid QSize in the gallery log

Changed in gallery-app (Ubuntu):
status: New → Confirmed
Changed in canonical-devices-system-image:
milestone: none → ww34-2015
assignee: nobody → Bill Filler (bfiller)
Bill Filler (bfiller)
Changed in canonical-devices-system-image:
importance: Undecided → High
status: New → In Progress
Arthur Mello (artmello)
Changed in gallery-app (Ubuntu):
status: Confirmed → In Progress
Revision history for this message
Arthur Mello (artmello) wrote :

When we tap in a photo, we are in fact opening a list of media that user can navigate when swiping right and left. The fact that we are seeing requests for videos when opening a photo is related with the way this list cache is implemented in gallery. With the new MR linked here, gallery should not request any thumbnail with (0, 0) but we still could request two videos thumbnails for each video. One for fullscreen and one for not fullscreen mode when in device (on desktop, we should request more sizes), since the sourceSize is linked with window height/width. Let me know if that is good enough or if we should go for a one size fits all approach, requesting a thumbnail big enough (maybe a single (0,0)) and using it as our thumbnail for all the window sizes.

Revision history for this message
Michi Henning (michihenning) wrote :

OK, so that explains the video thumbnails, thanks!

I think it's OK to ask for whatever images you actually want to display. I mean, after all, that's what the thumbnailer is for. If you were to always ask for some fixed size, then each and every time the thumbnail needs to be displayed, the GPU has to re-scale it. I suspect that's going to be harder on the battery and on performance than to simply ask for whatever size you want to show. That way, we scale each image only once.

Revision history for this message
Michi Henning (michihenning) wrote :

I just downloaded the PPA from silo 4 and tried it on Mako.

I'm still seeing lots of requests with invalid size (-1, -1).

To reproduce, take a few photos and videos, run "thumbnailer-admin clear", and start the gallery-app.

Looking at ~/.cache/upstart/application-click-com.ubuntu.gallery_gallery_2.9.1.1209.log, I see a whole bunch of requests with invalid size when I start the app.

Also, there appears to be another problem. (I'm watching ~/.cache/upstart/dbus.log for this.)

After I have my thumbnails on the events page, I can scroll all they way to the right by swiping left. With the list positioned at the far right, I briefly swipe left again. When I do that, I see that the app fires around twenty requests within about 400 ms, all for the same single image, all at size 256. I don't see why this should be necessary, seeing that the thumbnails being asked for are sitting there on the screen already.

Something similar happens when swipe right to to move the list back to the beginning, and swipe right again. However, there, I see only two requests, for two different thumbnails every time I swipe right. But, again, why are these requests happening, when the widget is already populated with thumbnails?

description: updated
Changed in canonical-devices-system-image:
status: In Progress → Fix Committed
Revision history for this message
Michi Henning (michihenning) wrote :

Pat, are you sure that's really fixed? Three days ago, when I tested from the silo, there were still problems (see comment #8).

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

Not sure I saw a vivid landing with the bug referenced, reopen if not fixed

Revision history for this message
Michi Henning (michihenning) wrote :

OK, I set it back to "Confirmed". I believe the issues in comment #8 are still there. If not, someone please set me straight! :-)

Changed in canonical-devices-system-image:
status: Fix Committed → Confirmed
Revision history for this message
Bill Filler (bfiller) wrote :

we have released the fix in latest gallery click package 2.9.1.1232
@artmello please verify if the issue in comment #8 is still present

Revision history for this message
Arthur Mello (artmello) wrote :

I tested on krillin (r94) with gallery (2.9.1.1232) and I am not able to see any invalid size request. We have multiple requests while loading events with different sizes (none invalid) for the same delegate but that is related with the current implementation of the event list andwe are working to improve that in another MR.
About the issue related with moving to the end/start of an event and when moving seeing multiples requests I can reproduce that and it seems to be fixed with setting the listView cache (currently gallery force it to cache nothing). We are changing that in the same MR I mentioned above.

Revision history for this message
Michi Henning (michihenning) wrote :

I don't have a krillilng, only a mako. I can test again with that. I'll grab the latest rc-proposed image and your gallery version. (It's still in the silo, I take it?)

Revision history for this message
Arthur Mello (artmello) wrote :

No, it was published. The fix should be on the rc-proposed image already

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package gallery-app - 0.0.67+15.10.20150806-0ubuntu1

---------------
gallery-app (0.0.67+15.10.20150806-0ubuntu1) wily; urgency=medium

  [ Arthur Mello ]
  * Fix the use of actionManager.localContexts to match last changes on
    it (LP: #1481920)
  * Fix thumbnail requests with invalid size on Events and Photos tab
    (LP: #1460993, #1467743)

  [ CI Train Bot ]
  * New rebuild forced.
  * Resync trunk.

 -- CI Train Bot <email address hidden> Thu, 06 Aug 2015 21:11:58 +0000

Changed in gallery-app (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Michi Henning (michihenning) wrote :

I just tried with image 217 from rc-proposed, and things look much better now. I don't see the invalid sizes anymore.

However, when pulling left when I'm at the end of my event list, I still get multiple requests for the same thumbnail. Right now, I'm seeing 18 requests for the same thumbnail being fired all at once each time I swipe left with the gallery positioned at the far right end.

Revision history for this message
Michi Henning (michihenning) wrote :

BTW, the number of duplicate requests seems to depend on the current layout of the event list. Sometimes I see two requests, sometimes five, sometimes a dozen. If you don't see what I'm describing, add a single photo at a time and try again. It seems to be worst when a single photo "sticks out" at the right-hand end of the list.

Revision history for this message
James Henstridge (jamesh) wrote :

The repeated reloading of thumbnails is due to gallery-app appending Date.now() to the image://thumbnailer URI. I've put together an MP that should fix this while still requesting new thumbnails when the file contents change here:

https://code.launchpad.net/~jamesh/gallery-app/thumbnail-mtime/+merge/268185

I built a test package that Michi says clears things up for him:

http://people.canonical.com/~jamesh/com.ubuntu.gallery_2.9.1.1234_armhf.click

What do we need to do to get this merged?

Revision history for this message
James Henstridge (jamesh) wrote :

Since "requesting the same image multiple times" isn't quite the same problem, I filed bug 1485490 and linked my branch to it there.

Bill Filler (bfiller)
Changed in canonical-devices-system-image:
status: Confirmed → Fix Committed
Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
Changed in thumbnailer (Ubuntu):
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.