Bug 74779 - Drawing an animated image to a canvas via drawImage should draw the first frame
: Drawing an animated image to a canvas via drawImage should draw the first frame
Status: NEW
Product: WebKit
Classification: Unclassified
Component: Canvas
: 528+ (Nightly build)
: Unspecified Unspecified
: P2 Normal
Assigned To: Nobody
http://www.whatwg.org/specs/web-apps/...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-16 20:44 PST by Boris Zbarsky
Modified: 2014-04-16 06:05 PDT (History)
11 users (show)

See Also:


Attachments
Image for testcase (143.73 KB, image/gif)
2012-03-03 05:31 PST, Boris Zbarsky
no flags Details
Testcase (361 bytes, text/html)
2012-03-03 05:33 PST, Boris Zbarsky
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Zbarsky 2011-12-16 20:44:47 PST
The spec at http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-drawimage is very clear:

  When the drawImage() method is passed an animated image as its image argument, the user
  agent must use the poster frame of the animation, or, if there is no poster frame, the
  first frame of the animation.

Presto, Trident, and Gecko get this right.
Comment 1 Alexey Proskuryakov 2011-12-20 09:49:56 PST
Which part of this does WebKit get wrong? Do you have a test case that you could attach?

I'm not an expert on this code, just trying to have all the necessary information captured in the bug.
Comment 2 Boris Zbarsky 2011-12-21 08:33:16 PST
http://jnglike.site40.net/rgba/basic.html seems to be an example where the current frame, not the first frame, is painted.
Comment 3 Lu Guanqun 2012-03-01 17:37:46 PST
(In reply to comment #2)
> http://jnglike.site40.net/rgba/basic.html seems to be an example where the current frame, not the first frame, is painted.

The above link is down, I get 404 error. Could you post another test example?
Comment 4 Boris Zbarsky 2012-03-01 19:22:38 PST
I gave you what I had.  That link was from someone complaining about an animation that worked in WebKit but not other browsers.

I guess if I come across something else I'll let you know.
Comment 5 Boris Zbarsky 2012-03-03 05:31:11 PST
OK, trivial testcase coming up.
Comment 6 Boris Zbarsky 2012-03-03 05:31:45 PST
Created attachment 130001 [details]
Image for testcase
Comment 7 Boris Zbarsky 2012-03-03 05:33:35 PST
Created attachment 130002 [details]
Testcase
Comment 8 Abhijeet Kandalkar 2013-05-30 21:33:14 PDT
In above mentioned test case Gecko's drawImage always paints the first frame of animated images.(Gecko mentioned that it is as per spec.)

While in case webkit,drawImage paints currentFrame.

There is bug related to same discussion in Mozilla bugzilla,
https://bugzilla.mozilla.org/show_bug.cgi?id=578514(Drawing an animated image into canvas does not work)

Mozilla is following spec here.

If Webkit also wants same behavior,I would like to fix this bug :)
Comment 9 Dirk Schulze 2014-04-03 04:39:35 PDT
(In reply to comment #8)
> In above mentioned test case Gecko's drawImage always paints the first frame of animated images.(Gecko mentioned that it is as per spec.)
> 
> While in case webkit,drawImage paints currentFrame.
> 
> There is bug related to same discussion in Mozilla bugzilla,
> https://bugzilla.mozilla.org/show_bug.cgi?id=578514(Drawing an animated image into canvas does not work)
> 
> Mozilla is following spec here.
> 
> If Webkit also wants same behavior,I would like to fix this bug :)

Since you can not control the time or the frame you want to use, I agree that we should just paint the first frame (or poster image).  Abhijeet, do you want to take a look?