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 769960 - animated WebP loader is not properly handling blending and transparency
animated WebP loader is not properly handling blending and transparency
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: Normal normal
: 2.10
Assigned To: GIMP Bugs
Depends on:
Reported: 2016-08-16 00:29 UTC by pascal.massimino
Modified: 2016-09-07 15:22 UTC
See Also:
GNOME target: ---
GNOME version: ---

animated webp file demonstrating the reconstruction problem (20.44 KB, image/webp)
2016-08-16 00:29 UTC, pascal.massimino
patch for fixing animation decoding (3.36 KB, patch)
2016-08-16 00:30 UTC, pascal.massimino
none Details | Review
updated patch fixing animation decoding (3.38 KB, patch)
2016-08-16 16:25 UTC, pascal.massimino
none Details | Review
updated patch fixing animation decoding (3.57 KB, patch)
2016-08-16 22:34 UTC, pascal.massimino
none Details | Review
torture test bitstream for webp animation + ICC (419.07 KB, image/webp)
2016-08-22 08:50 UTC, pascal.massimino
WebP animation decoding fix (4.44 KB, patch)
2016-08-24 09:38 UTC, pascal.massimino
committed Details | Review

Description pascal.massimino 2016-08-16 00:29:04 UTC
Created attachment 333386 [details]
animated webp file demonstrating the reconstruction problem

the current webp file-loader is not reconstructing frame correctly.

Attached, a small (well-known? :)) animation that demonstrate the problem.
Using Filters -> Animation -> Playback tool, once can see the first frame is scrambled.

Using WebPAnimDecoder API solves the problem (reconstruction is handled by libwebpdemux directly).

Fix patch following up.
Comment 1 pascal.massimino 2016-08-16 00:30:34 UTC
Created attachment 333387 [details] [review]
patch for fixing animation decoding

switch to WebPAnimDecoder API.
Comment 2 pascal.massimino 2016-08-16 16:25:54 UTC
Created attachment 333434 [details] [review]
updated patch fixing animation decoding

Here's a rebased patch, with coding style fixes
Comment 3 Jehan 2016-08-16 19:11:35 UTC
For authorship, could you tell us your full name? I assume this is Pascal Massimino, from the email address. But just to be sure…
Comment 4 pascal.massimino 2016-08-16 20:10:36 UTC
indeed, that's Pascal Massimino.
Comment 5 Urvang Joshi 2016-08-16 21:25:38 UTC
Review of attachment 333434 [details] [review]:

Looks good. A couple of optional comments...

::: plug-ins/file-webp/file-webp-load.c
@@ +168,1 @@
+      dec = WebPAnimDecoderNew (&wp_data, NULL);

I'd suggest adding a note that this defaults to "RGBA" color mode.

@@ +177,3 @@
+          g_printerr ("Failed to decode animated WebP information\n");
+          WebPAnimDecoderDelete (dec);
+          return -1;

If 'goto' is allowed, maybe 'goto Err' here and the cleanup can be handled in one place?
Comment 6 Ben 2016-08-16 22:30:26 UTC
@pascal What version of libwebp were you using? Also did you test this patch to make sure that the metadata and icc profiles still load properly?
Comment 7 Ben 2016-08-16 22:32:16 UTC
@Pascal For the metadata requires installing exiv2 from git to test with.
Comment 8 pascal.massimino 2016-08-16 22:34:27 UTC
Created attachment 333442 [details] [review]
updated patch fixing animation decoding

updated patch fixing animation decoding
Comment 9 pascal.massimino 2016-08-17 00:10:17 UTC
@Ben the metadata code didn't change (it's before and after the section i modified). I just modified the code handling decoding of individual frames.

I'm testing with latest libwebp 0.5.1.
Comment 10 pascal.massimino 2016-08-22 08:50:46 UTC
Created attachment 333870 [details]
torture test bitstream for webp animation + ICC

generated using the initial 'farbkreis.jpg' image reported here:
Comment 11 pascal.massimino 2016-08-22 08:51:27 UTC
Please find attached a 'torture' bitstream anim_icc.webp for exercising webp+animation+alpha+ICC+strange timestamps.

I generated this bitstream starting from the infamous 'farbkreis.jpg' image that was once reported on Chromium project[1]. Then i just created a rotating animation of it, transferring the ICC data into anim_icc.webp.

In GIMP, the labeled texts should be displayed with the correct colors if ICC is supported. The new patch didn't break this behaviour.

Comment 12 Ben 2016-08-22 09:27:17 UTC
It works fine here, i'm not seeing any problems. I see in GIMP the same i did in Chromium and the colors match the sections of the wheel. You have to keep the profile when it loads in GIMP or else the profile will default to GIMPs default SRGB profile (or whatever is your default set to).
Comment 13 Ben 2016-08-22 09:44:34 UTC
It does seem to fail in other browsers but how is that GIMPs problem if color management isn't respected in other software?
Comment 14 Ben 2016-08-22 09:52:37 UTC
Converting it to SRGB seems makes it work in all browsers. So i'm not really sure what the issue is?
Comment 15 pascal.massimino 2016-08-22 09:58:04 UTC
Embarrassingly, animated WebP + ICC is *not* supported by Chrome.

This is a long-standing unresolved issue (see code [1]).

The main reason for this gap is performance: having to apply the ICC profile to all pixels, in combination with alpha, is involved and CPU-consuming.
It was dropped, being considered a corner case, pretty much like ICC is not supported in animated GIFs (same reason).

Comment 16 Ben 2016-08-22 10:06:35 UTC
Lol. Maybe my coffee is defective this morning but I still don't get what this has to do with GIMP?
Comment 17 pascal.massimino 2016-08-22 11:22:18 UTC
i mentioned Chromium's code because anim_icc.webp is an example of bitstream that will show differently in Chrome and GIMP (that's related to comment #12). And also why this is likely to stay so for a while.
Comment 18 Jehan 2016-08-23 00:40:42 UTC
Pascal > I don't see big issues in your patch but for minor styling issues. Like you forgot a space between a function and the parentheses (at least once), and we try to align variable declarations. Also please when initializing a pointer, that's NULL, not 0.

Ben > I think Pascal just made a digression to answer your question in comment 6 (i.e. does it still load ICC profiles properly?). So basically just showing that the profile was still properly applied on the webm before and after the patch (not saying there is a bug here).

Anyway testing, it does look like it indeed fixes the first frame being scrambled on mosaic.webp (assuming this is not how it was supposed to look. I did not look at the webp format itself). Should we apply the commit?
Comment 19 pascal.massimino 2016-08-24 09:25:43 UTC
#18: Jehan, let me fix the few style issues in a subsequent patch.
Comment 20 pascal.massimino 2016-08-24 09:38:32 UTC
Created attachment 334064 [details] [review]
WebP animation decoding fix

updated patch with coding style fixes
Comment 21 Michael Natterer 2016-09-04 16:58:20 UTC
Thanks, fixed in master with some cleanup:

commit 252da1bdd5724789428dd95689de55bed8e5abb8
Author: Pascal Massimino <>
Date:   Wed Aug 24 11:29:58 2016 +0200

    Bug 769960 - animated WebP loader is not properly handling blending...
    ...and transparency
    Use most recent API for decoding WebP animation. WebPAnimDecoder
    handles transparency and blending automatically.

 plug-ins/file-webp/file-webp-load.c | 89 ++++++++++++++++++++-----------------
 1 file changed, 48 insertions(+), 41 deletions(-)
Comment 22 pascal.massimino 2016-09-07 15:22:35 UTC
Thanks for merging the patch!

Next, I posted a follow-up patch for the webp-saving part: