Bug 55830 - REGRESSION: Animated gifs blink and cause high CPU usage
Summary: REGRESSION: Animated gifs blink and cause high CPU usage
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Other
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-05 15:10 PST by David
Modified: 2011-03-08 10:43 PST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David 2011-03-05 15:10:50 PST
http://www.openbsd.org/art/banners/banner1.gif

With webkit 1.2.7, that image blinks instead of animating.

Backing out change listed at http://gitorious.org/webkitgtk/stable/commit/d842bb085aceec4fcfc392a7b76c92c258cd5151 fixes the issue.
Comment 1 Alexey Proskuryakov 2011-03-05 23:30:19 PST
This is extremely strange. How can a change in SMIL code possibly affect animated GIFs?
Comment 2 David 2011-03-06 06:04:50 PST
Are you able to confirm?
Comment 3 Marco Peereboom 2011-03-06 06:17:36 PST
I see this bug too and reverting that code works for me as well.
Comment 4 Nikolas Zimmermann 2011-03-06 07:29:57 PST
This sounds impossible. SMIL is not involved when displaying gifs.
Comment 5 Marco Peereboom 2011-03-06 08:20:48 PST
"Impossible" or "extremely strange" doesn't change the fact that webkit regressed with this change.
Comment 6 Nikolas Zimmermann 2011-03-06 08:40:22 PST
(In reply to comment #5)
> "Impossible" or "extremely strange" doesn't change the fact that webkit regressed with this change.

Nope, there must be another reason, either corrupted builds, whatever, there is no SMIL involved, believe me. This code path is never executed when displaying gifs. It's about animating SVG documents.

What's the testcase you're using? Just viewing the gif, embedding the gif in a SVG document, or a HTML document? We need more input to judge.
Comment 7 David 2011-03-06 08:49:16 PST
in my original report, i pasted a direct link to a gif.

Do you show it as blinking or animated?
Comment 8 Dirk Schulze 2011-03-06 09:37:54 PST
Which svn revision is d842bb085aceec4fcfc392a7b76c92c258cd5151? Btw. I tried a chromium snapshot from March 3rd, but didn't see a problem with the gif. The image looks the same like in Safari 5, animated.
Comment 9 Tobias Ulmer 2011-03-07 06:46:28 PST
I can confirm that the gif just flickers on Archlinux i686 with libwekkit-1.2.7-1 and midori-0.3.2-1.
Comment 10 David 2011-03-07 13:04:53 PST
oops.

I had two patches applied.

It seems the following change is the culprit.  Backing this one out makes animations work again.   Does this one make more sense? :)

http://trac.webkit.org/changeset/68446/trunk/WebCore/platform/image-deco
ders/gif/GIFImageDecoder.cpp
Comment 12 Peter Kasting 2011-03-07 13:30:59 PST
(In reply to comment #11)
> http://trac.webkit.org/changeset/68446/trunk/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp

What port is broken here?  If you look at the full patch there, you'll see that it only changed behavior on Skia.  AFAIK that's only used for Chromium, which displays this GIF correctly in my tests.

I just checked the current ImageDecoder*.cpp files and no one but Skia ever returns false from this function, so unless you're using a Skia-based port this change can't have affected you.
Comment 13 Marco Peereboom 2011-03-07 13:53:57 PST
Per Comment #9 From Tobias Ulmer 2011-03-07 06:46:28 PST

I can confirm that the gif just flickers on Archlinux i686 with libwekkit-1.2.7-1 and midori-0.3.2-1.

So that is not just chromium
Comment 14 Peter Kasting 2011-03-07 13:55:02 PST
(In reply to comment #13)
> Per Comment #9 From Tobias Ulmer 2011-03-07 06:46:28 PST
> 
> I can confirm that the gif just flickers on Archlinux i686 with libwekkit-1.2.7-1 and midori-0.3.2-1.
> 
> So that is not just chromium

Yes, I saw that comment.  I have no idea what port that is or what code it uses.  So it doesn't answer my question.
Comment 15 David 2011-03-07 14:00:07 PST
Here is a diff that causes "a1 = 1" to flood my xterm.  So, it does indeed hit the code path.



--- GIFImageDecoder.cpp.orig    Mon Mar  7 16:59:34 2011
+++ GIFImageDecoder.cpp Mon Mar  7 16:49:46 2011
@@ -342,10 +342,11 @@
         ASSERT(prevBuffer->status() == RGBA32Buffer::FrameComplete);
 
         if ((prevMethod == RGBA32Buffer::DisposeNotSpecified) || (prevMethod == RGBA32Buffer::DisposeKeep)) {
-            // Preserve the last frame as the starting state for this frame.
-            if (!buffer->copyBitmapData(*prevBuffer));
-                return setFailed();
-        } else {
+            int a1;
+               // Preserve the last frame as the starting state for this frame.
+            a1 = buffer->copyBitmapData(*prevBuffer);
+               printf("a1 = %d\n", a1);  
+      } else {
             // We want to clear the previous frame to transparent, without
             // affecting pixels in the image outside of the frame.
             const IntRect& prevRect = prevBuffer->rect();
@@ -356,10 +357,11 @@
                 if (!buffer->setSize(bufferSize.width(), bufferSize.height()))
                     return setFailed();
             } else {
+               int a2;
               // Copy the whole previous buffer, then clear just its frame.
-              if (!buffer->copyBitmapData(*prevBuffer));
-                  return setFailed();
-              for (int y = prevRect.y(); y < prevRect.bottom(); ++y) {
+              a2 = buffer->copyBitmapData(*prevBuffer);
+              printf("a2 = %d\n", a2);
+               for (int y = prevRect.y(); y < prevRect.bottom(); ++y) {
                   for (int x = prevRect.x(); x < prevRect.right(); ++x)
                       buffer->setRGBA(x, y, 0, 0, 0, 0);
               }
Comment 16 David 2011-03-07 14:15:29 PST
here is your patch to fix it.  


--- GIFImageDecoder.cpp.orig    Mon Mar  7 16:59:34 2011
+++ GIFImageDecoder.cpp Mon Mar  7 17:14:09 2011
@@ -343,7 +343,7 @@
 
         if ((prevMethod == RGBA32Buffer::DisposeNotSpecified) || (prevMethod == RGBA32Buffer::DisposeKeep)) {
             // Preserve the last frame as the starting state for this frame.
-            if (!buffer->copyBitmapData(*prevBuffer));
+            if (!buffer->copyBitmapData(*prevBuffer))
                 return setFailed();
         } else {
             // We want to clear the previous frame to transparent, without
@@ -357,7 +357,7 @@
                     return setFailed();
             } else {
               // Copy the whole previous buffer, then clear just its frame.
-              if (!buffer->copyBitmapData(*prevBuffer));
+              if (!buffer->copyBitmapData(*prevBuffer))
                   return setFailed();
               for (int y = prevRect.y(); y < prevRect.bottom(); ++y) {
                   for (int x = prevRect.x(); x < prevRect.right(); ++x)
Comment 17 Peter Kasting 2011-03-07 14:35:20 PST
Your fork/branch/checkout/what-have-you is broken.  You have a trailing semicolon after the calls to copyBitmapData() that does not exist in the changeset you cited or on the trunk.  The "patch to fix" is a patch that makes the code look like what trunk already looks like (and always has looked like).

To put this another way, whoever constructed the particular libraries in Archlinux did it wrong, and the fix should go into whatever location those are built out of.
Comment 18 David 2011-03-07 14:52:41 PST
ahh, the webkitgtk branch is where it exists.
Comment 19 Marco Peereboom 2011-03-07 14:53:54 PST
You are right.  That file seems correct in the trunk however it is busted in the tarball that is provided by http://webkitgtk.org/?page=download

The contribute link on the webkitgtk to report bugs goes to bugs.webkit.org.

So whomever runs the show on the webkitgtk checkout made a merging mistake (or something).  How does one get fixes into webkitgtk?  Is it not the same bug tracker?
Comment 20 Alexey Proskuryakov 2011-03-08 10:43:14 PST
Followup in bug 55937.