New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Oct 2016
Cc:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment
link

Issue 592735: GIF animation loops once more than it should

Reported by urvang@chromium.org, Mar 7 2016 Project Member

Issue description

Version: 48.0.2564.116
OS: Linux

What steps will reproduce the problem?
(1) Open the attached GIF image in Chrome

What is the expected output? What do you see instead?

The loop_count stored in the file is 2, so it should loop 2 times; but animation loops 3 times.


Refer to this info on loop count: http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension

Also, Firefox has the correct behavior (animation loops 2 times).
 

Comment 1 by urvang@chromium.org, Mar 8 2016

Cc: noel@chromium.org

Comment 2 by urvang@chromium.org, Mar 8 2016

full2loop.gif
648 bytes View Download

Comment 3 by noel@chromium.org, Mar 8 2016

Cc: pkasting@chromium.org
IE-11 appears to loop 3 times.  Did you test Safari?  On matters of GIF loop count, Peter might be the best reviewer.

Comment 4 by urvang@chromium.org, Mar 8 2016

I'll test on Safari on mac later today.

Meanwhile, as far as ImageMagick goes, it agrees that the loop count is 2. As mentioned in this patch http://crrev.com/1767063003, you can run "identify -verbose full2loop.gif | grep 'Iterations'" to check this.

Comment 5 by pkasting@chromium.org, Mar 8 2016

This issue has been contentious over the years.  The disagreement is about how to read the word "loop":

For loop count n,
(a) Decode and display the image normally, then loop it again n times
(b) Decode and display the image for a total of n loops

Another argument is about the display-exactly-once case.  Proponents of (b) argue that (a) makes no sense because it contains no provision for displaying exactly once.  Proponents of (a) argue that that's the normal case without the loop count extension block, and there's no reason to add such a block to your GIF just to say that you want to do the same thing you would have done anyway.

IE and Edge match Chromium.  I don't have a Mac to test Safari, but I'll bet it matches Chromium.  At least on Win 10, the Windows photo app (the closest thing to a "native viewer" I can find) also matches Chromium.

Historically, Firefox also matched this behavior.  They changed this in https://bugzilla.mozilla.org/show_bug.cgi?id=222176 .  On the bug at the time (see https://bugzilla.mozilla.org/show_bug.cgi?id=222176#c13 ), it was argued that Opera, Chrome, and "Windows internal image viewer" had the behavior you want.  I am a bit skeptical of this; I believe at the time Chrome and Safari set the current behavior as default it matched IE and Firefox.  The bug claims that "JASC Animation Shop" at the time expected browsers to behave like current Chromium; I haven't tested any image creation tools to see what the case is today.

Assuming Safari does match Chromium, I believe the right thing to do here is to file a bug against Firefox requesting they revert the change from https://bugzilla.mozilla.org/show_bug.cgi?id=222176 , and linking to this bug or restating the arguments made here.  The other route is to try to get consensus from Microsoft and Apple that it makes sense for everyone to change this.

In a perfect world, I think spec interpretation (b) is more compelling.  However, I'm concerned with web compat issues if most browsers have done (a) for years.

Comment 6 by urvang@chromium.org, Mar 8 2016

I see. Thanks for all the context Peter. I think what makes this contentious is that loop count is an "Application extension", so it's not really part of the GIF spec (https://www.w3.org/Graphics/GIF/spec-gif89a.txt).
And I couldn't find an official documentation for the Netscape loop count extension. In fact, top web search links and other GIF related pages seem to point to this unofficial documentation: http://www.vurdalakov.net/misc/gif/netscape-looping-application-extension

Let me check the behavior on Safari later today, when I have a Mac with me. And we can decide how to proceed.

Comment 7 by urvang@chromium.org, Mar 9 2016

I tested Safari: it seems to loop the animation 3 times as well (matching current behavior of Chromium and IE/Edge you guys reported).

So, as Peter suggested, I think best course of action is to (1) file a bug against Firefox to match other browsers for GIF and (2) Match behavior of animated WebP with GIF on Chromium.

So, unless someone speaks up otherwise, I'll go ahead with that.

Comment 8 by noel@chromium.org, Mar 10 2016

A view of the test image (full2loop.gif) that shows what frames are within it ... (attached).

And confirm, viewing in Safari 9.0.3, the yellow frame is shown three times.

So yeap, there's a browser compat issue to resolve (file a Firefox bug), and webp animated needs to align with the rest of the GIF world.  Sounds like a plan.
full-loop-gif-image-sequence.png
5.3 KB View Download

Comment 9 by urvang@chromium.org, Mar 10 2016

Firefox bug: https://bugs.chromium.org/p/chromium/issues/detail?id=592735#c5
Chrome patch to match WebP behavior with GIF: http://crrev.com/1780463007

Comment 10 by pkasting@chromium.org, Mar 10 2016

You provided the wrong link for the Firefox bug.

Comment 11 by urvang@chromium.org, Mar 10 2016

Comment 12 by bugdroid1@chromium.org, Mar 11 2016

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/77ed91ec5600ab1331c2faafc1c245a2d33b28a5

commit 77ed91ec5600ab1331c2faafc1c245a2d33b28a5
Author: Urvang Joshi <urvang@google.com>
Date: Fri Mar 11 01:16:08 2016

Add a GIF test file to test loop count behavior

This file has a loop count of 2, which can be verified by running:
"identify -verbose full2loop.gif | grep 'Iterations'"

This test file will be used in a unit test in the next patch.

BUG= 592735 
R=noel@chromium.org, pkasting@chromium.org

Review URL: https://codereview.chromium.org/1767063003 .

Cr-Commit-Position: refs/heads/master@{#380505}

[add] https://crrev.com/77ed91ec5600ab1331c2faafc1c245a2d33b28a5/third_party/WebKit/LayoutTests/fast/images/resources/full2loop.gif

Comment 13 by bugdroid1@chromium.org, Mar 12 2016

Project Member
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a45163dc68252ce3f1958ab58b06a765e652eb70

commit a45163dc68252ce3f1958ab58b06a765e652eb70
Author: urvang <urvang@chromium.org>
Date: Sat Mar 12 00:22:28 2016

GIF decoding: Add a unit test for repetition count

Also add a test to BitmapImageTest to ensure we loop one
extra time when animating.

BUG= 592735 

Review URL: https://codereview.chromium.org/1769343002

Cr-Commit-Position: refs/heads/master@{#380800}

[modify] https://crrev.com/a45163dc68252ce3f1958ab58b06a765e652eb70/third_party/WebKit/Source/platform/graphics/BitmapImageTest.cpp
[modify] https://crrev.com/a45163dc68252ce3f1958ab58b06a765e652eb70/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoderTest.cpp

Comment 14 by bugdroid1@chromium.org, Mar 12 2016

Project Member

Comment 15 by urvang@chromium.org, Mar 14 2016

Status: Fixed (was: Assigned)
This is done now:
- GIF behavior turned out to be consistent with other browsers, so just added tests for current behavior.
- Changed WebP animation to behave similar to GIF.
- Filed a firefox bug so that they match Chromium and other browsers.

Comment 16 by gn00742...@gmail.com, Sep 7 2016

After webp animation loop once more than stored loop count,

there is no way to play only once,

how to solve this?

Comment 17 by pkasting@chromium.org, Sep 7 2016

Don't have a loop count at all?  That's how you make a play-once GIF.

Comment 18 by gn00742...@gmail.com, Sep 8 2016

https://developers.google.com/speed/webp/docs/webpmux

loop option default value is 0,

if you didn't set loop,

WebP animation will loop infinite.

Comment 19 by pkasting@chromium.org, Sep 8 2016

Not setting a -loop value at all ought to not write a loop count into the file, at which point the browser should treat it as non-looping.  If this isn't the case, I consider it either a bug in webpmux or the WebP format itself, as the goal of the change in comment 14 was to harmonize WebP with GIF, and that's how GIF does non-looping animations.

Neither of those would be a Chrome bug, though, and I'm not the WebP format expert.

Comment 20 by gn00742...@gmail.com, Sep 8 2016

Is any chance to revert comment 14?

although that will cause webp and gif behavior not harmonize, but it's can play webp animation only once at least.

It's no way to play webp once on current version:(

Comment 21 by pkasting@chromium.org, Sep 8 2016

Urvang would have to comment on whether there is, in fact, some way to do what you want.

I agree that we don't want to be in a situation where there's truly no way to make a play-once .webp.

Comment 22 by gn00742...@gmail.com, Sep 15 2016

any update?

Comment 23 by schenney@chromium.org, Oct 13 2016

Cc: schenney@chromium.org
Status: Started (was: Fixed)
Blocked on webp https://bugs.chromium.org/p/webp/issues/detail?id=309

I'll try to get their attention on this issue.

Comment 24 by schenney@chromium.org, Oct 13 2016

Status: Fixed (was: Started)

Comment 25 by schenney@chromium.org, Oct 13 2016

Sign in to add a comment