Bug 63314 - Can only render first frame of animated gifs to canvas if image is hidden
Summary: Can only render first frame of animated gifs to canvas if image is hidden
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: http://robothaus.org/bugs/gifs/gif-hi...
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-23 23:40 PDT by bobby
Modified: 2022-07-18 14:03 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bobby 2011-06-23 23:40:43 PDT
When an animated gif is being rendered by an <img>, grabbing its pixels with a drawImage() is possible. But, as soon as that gif becomes invisible by any means other than simply moving it off the screen with, say, a negative "left" position, drawImage only grabs the first frame of the gif.

Can we not have the <img> tag continue to update when it's not displayed for the sake of using them in animations? WebGL textures would be super fun.

Test 1: http://robothaus.org/bugs/gifs/gif-hidden-test.html - canvas will update properly for 2 seconds, and then <img> will become invisible and canvas will stop updating, even though drawImage is still being called.

Test 2: http://cjcliffe.github.com/CubicVR.js/cubicvr/tests/gifs/gifs.html - WebGL texture fun with gif simply moved to 'left: -600px'.

I'm using chromium 12.0.742.100 (0).
Comment 1 Peter Kasting 2011-06-24 13:46:26 PDT
We purposefully don't animate invisible GIFs for CPU load reasons -- for example, on some long forum pages with hundreds of animated GIFs, drawing offscreen GIFs can easily bring the browser to its knees.

I don't know the drawing pipeline well enough to say whether there's some specific change we could put in place to support just this particular case.  Mark might know more.
Comment 2 bobby 2011-06-24 13:49:18 PDT
That doesn't really seem to be the case here. It renders fine when gifs are off-screen, just not when they have their visibility tampered with.

Which is more broken? :/
Comment 3 Matthew Delaney 2011-06-24 13:54:02 PDT
What's meant by invisible here? I'd imagine that we'd treat a gif far down a forum page (out of view) the same as one that is hanging off the left side of the page (out of view).

@Bobby, is there any benefit from having visibility set rather than having it positioned off the screen? Not sure I understand what the issue is here if you can do it equally fine with left: -something
Comment 4 bobby 2011-06-24 13:59:59 PDT
@Matt: just seems kind of silly to have to do that. If scrollbars are present on the screen, you can just scroll over and see the gif, right?
Comment 5 Matthew Delaney 2011-06-24 14:02:37 PDT
(In reply to comment #4)
> @Matt: just seems kind of silly to have to do that. If scrollbars are present on the screen, you can just scroll over and see the gif, right?

Yea, I suppose setting the opacity to 0 or something would be the first thing I'd try, though it'll still be laid out somewhere on the page, so you'd have to deal with that.

Alternatively you could hide it behind the canvas that you're drawing into. Or in the left: -something case, you could just have overflow:hidden for its container to avoid scrolling.
Comment 6 Mark Rowe (bdash) 2011-06-24 14:06:52 PDT
If it’s positioned offscreen to the left or top then you’ll never be able to scroll to reveal it, even if the page is scrollable.
Comment 7 bobby 2011-06-25 06:34:50 PDT
Ok, that's good enough, I suppose. Just seemed awkward while I was getting it to work, but, hey, this is the fun side of the internet :).

Thanks guys.
Comment 8 Brent Fulgham 2022-07-18 14:03:06 PDT
The relevant test sites no longer exist. We can't take further action on this bug report.