Attached gif downloaded from telegram takes out the phone as thumbnailer hogs the memory and cpu

Bug #1527315 reported by Dave Morley
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
High
Alejandro J. Cura
thumbnailer (Ubuntu)
Fix Released
Critical
Michi Henning

Bug Description

STEPS:
1. drop the attached gif into the Photo's folder
2. Open gallery
3. Refresh the photo's scope

ISSUE:
The gif I think causes thumbnailer to loop, Memory usage jump 4% each loop until oom takes out the app but thumbnailer is still stuck in it's loop so eventually the scopes are all taken out, At that point thumbnailer is stopped and the system returns to normal with the exception that there is now a black space where the scopes used to be.

IMAGE:
Krillin ota 8.5

Tags: qa-dogfood

Related branches

Revision history for this message
Dave Morley (davmor2) wrote :
Dave Morley (davmor2)
tags: added: qa-dogfood
Changed in canonical-devices-system-image:
status: New → Confirmed
importance: Undecided → High
milestone: none → ww02-2016
Changed in thumbnailer (Ubuntu):
importance: Undecided → High
assignee: nobody → Michi Henning (michihenning)
Revision history for this message
Michi Henning (michihenning) wrote :

That's a pretty stupid way to make a video. A real video would probably be a lot small and have better quality :-)

But I agree that we shouldn't fall over just because someone feeds us a file like this. I'll have a look at what's going on.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Not optimal but fun. I made the same silly mistake recently thinking GIFs would be cool. But you lose colour depth (GIFs are indexed 256 colour at most) so get dithered, and the GIF files were bigger than the original MP4s. Not clever, but fun.

GIFs have two significant advantages though:
  1. A longer history of support across many web browsers (decades); and
  2. They are temporally lossless, which is good for detail (although spatially lossy in colour).

I'm still a little shocked that GIFs still exist in this century...

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

I shudder to think what this video would do to global warming if it happened to go viral… ;)

Come to think of it, how much global warming is caused by cat videos? Would be an interesting research project…

Changed in canonical-devices-system-image:
assignee: nobody → Michi Henning (michihenning)
Revision history for this message
Michi Henning (michihenning) wrote :

The gif contains 491 frames at 960 by 540. Uncompressed, that's half a MB per frame, for a total of 254 MB. So, during scaling with gdk_pixbuf, we have at least this much in memory, plus a copy of the scaled result. Little wonder that things break.

I'll see if we can change things such that we extract a single frame and then scale that. (It's not a trivial change, so this will take a while.)

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

With the devel branch at 317, the thumbnailer copes with the animated gif just fine, in the sense that it correctly comes up with a thumbnail. It takes 6 seconds though, and memory temporarily climbs to 1.2 GB.

Changed in canonical-devices-system-image:
assignee: Michi Henning (michihenning) → Alejandro J. Cura (alecu)
Changed in thumbnailer (Ubuntu):
status: New → In Progress
Revision history for this message
Michi Henning (michihenning) wrote :

Elevated this to critical because the thumbnailer service is permanently toast if someone actually does add a GIF image that blows the memory limits imposed by the OOM watchdog.

If that happens in the field, it's good-bye thumbnailer service whenever any app or scope asks for a thumbnail for the offending file. The bug will be rare but, when it strikes, it's absolutely fatal.

Changed in thumbnailer (Ubuntu):
importance: High → Critical
Changed in canonical-devices-system-image:
status: Confirmed → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package thumbnailer - 2.3+16.04.20160108.2-0ubuntu1

---------------
thumbnailer (2.3+16.04.20160108.2-0ubuntu1) xenial; urgency=medium

  [ Michi Henning ]
  * Fixed incorrect display of cache policy by "thumbnailer-admin stats".
  * Limit GIF file size to 2 MB (LP: #1527315).

  [ CI Train Bot ]
  * No-change rebuild.

 -- Michi Henning <email address hidden> Fri, 08 Jan 2016 12:43:17 +0000

Changed in thumbnailer (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
James Henstridge (jamesh) wrote :

We should have a better fix for this in the next Thumbnailer landing: rather than blacklisting large GIF files, I worked out how to convince gdk-pixbuf to stop once we read enough to decode the first frame.

This makes the attached 45MB GIF file thumbnail almost instantly, without ballooning memory usage or having to read the entire file.

Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
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.