Bug 23082

Summary: REGRESSION: Animated GIF as CSS background fails to animate
Product: WebKit Reporter: Simon Fraser (smfr) <simon.fraser>
Component: ImagesAssignee: Simon Fraser (smfr) <simon.fraser>
Status: RESOLVED FIXED    
Severity: Normal CC: hyatt, pkasting, webkit, webkit, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
URL: http://aislian.org/tile.html
Attachments:
Description Flags
Patch, testcase, changelog darin: review+

Description Simon Fraser (smfr) 2009-01-02 15:33:14 PST
When an animated GIF is used as a CSS background-image, it fails to animate. This works in Safari 3.2.
Comment 1 Simon Fraser (smfr) 2009-01-02 16:21:33 PST
This is caused by bug 19663.
Comment 2 Simon Fraser (smfr) 2009-01-02 16:46:13 PST
Created attachment 26386 [details]
Patch, testcase, changelog

This was a regression from bug 19663, which changed the signature of startAnimation() in BitmapImage, but not in the base class.
Comment 3 Darin Adler 2009-01-02 16:48:02 PST
Comment on attachment 26386 [details]
Patch, testcase, changelog

r=me
Comment 4 Simon Fraser (smfr) 2009-01-02 16:48:56 PST
*** Bug 22647 has been marked as a duplicate of this bug. ***
Comment 5 Simon Fraser (smfr) 2009-01-02 17:06:20 PST
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	LayoutTests/ChangeLog
	A	LayoutTests/fast/backgrounds/animated-gif-as-background.html
	A	LayoutTests/fast/backgrounds/resources/red-green-animated.gif
	A	LayoutTests/platform/mac/fast/backgrounds/animated-gif-as-background-expected.checksum
	A	LayoutTests/platform/mac/fast/backgrounds/animated-gif-as-background-expected.png
	A	LayoutTests/platform/mac/fast/backgrounds/animated-gif-as-background-expected.txt
	M	WebCore/ChangeLog
	M	WebCore/platform/graphics/Image.h
Committed r39564
Comment 6 Robert Blaut 2009-01-05 11:42:33 PST
This fix doesn't work for me in WebKit r39572 on Mac OS X.
Comment 7 Simon Fraser (smfr) 2009-01-05 11:46:28 PST
Robert: what is your testcase?

http://aislian.org/tile.html does fail for me sporadically (when the GIF is not cached?).
Comment 8 Robert Blaut 2009-01-05 11:55:18 PST
(In reply to comment #7)
> Robert: what is your testcase?
> 
> http://aislian.org/tile.html does fail for me sporadically (when the GIF is not
> cached?).
> 

I tested this reported URL. It doesn't work completely for me.
Comment 9 Scott Perry 2009-01-05 20:42:50 PST
(In reply to comment #7)
> http://aislian.org/tile.html does fail for me sporadically (when the GIF is not
> cached?).

when the gif is not cached and when you view the image before it is finished loading

if I let a gif load completely in a background tab before viewing it, the gif always animates correctly (using Webkit nightly on OS X at least).
Comment 10 Peter Kasting 2009-01-06 10:24:58 PST
While I don't know precisely what's going on here, in general the reason for this kind of issue is that the image animation won't advance to incomplete frames and won't advances past the end of the image for non-repeating images; if a frame never gets marked complete, or the repeat count is erroneously set to "don't repeat", or draw() doesn't get called again when new data comes in from the network layer, the animation won't advance.

Similar issues in the past:

* In the original patch to bug 19663, the image rect was getting cleared by draw() when no animation timers were running, and thus nothing would ever automatically re-call draw() (and hence re-call startAnimation() to keep the animation moving).  You can see in the final patch on that bug that there's a big comment about this in startAnimation() along with an explicit call back to startAnimation() again to keep the timer going in this case.

* In bug 22108 the decoder was being destroyed mid-stream, and if it was then re-queried for the repeat count, it would return a bogus value.  That patch fixed this issue by not deleting the decoder.
Comment 11 Peter Kasting 2009-01-06 13:50:18 PST
I'm going to call the remainder of this a dupe of bug 22995, which I've just taken, and re-close this bug, claiming it's just about the bogus method signature portion.