W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2010

Re: requestAnimationFrame

From: Robert O'Callahan <robert@ocallahan.org>
Date: Thu, 18 Nov 2010 14:20:15 +1300
Message-ID: <AANLkTikXBaHrX9bWrTeBnzcVCqGraCX=Q2aft7EFt593@mail.gmail.com>
To: "Gregg Tavares (wrk)" <gman@google.com>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "public-webapps@w3.org" <public-webapps@w3.org>
On Thu, Nov 18, 2010 at 11:22 AM, Gregg Tavares (wrk) <gman@google.com>wrote:

> Think about this some more..... the point if the previous suggestion is
> that updating keeping a JS animation in sync with a CSS animation has
> nothing to do with "painting" or rendering. The fact that apparently firefox
> ties those 2 things together is an artifact of firefox's implementation.
> It's just has valid to for example have animation running on 1 thread and
> rendering on another. Many console/pc games do this. To keep animations in
> sync requires syncing the animation values in the animation thread, not
> deciding to update values during rendering.


But for maximum smoothness you want to update your animation once per
painted frame. It doesn't matter how many threads you use and whether you do
it "during" rendering.


> So, if the goal is to let JS sync with CSS animations, putting the in
> events related to painting is the wrong model. Solving that problem
> particular goal it would make more sense to add a "cssAnimationTick" event
> or something.  Any JS that wants to say in sync would add an event handler
>
> window.addEventHandler('animationTick", updateAnimations, ...);
>
> The handler would get passed a clock similar to how beforePaint works now.
>

Let's not get hung up on the "beforePaint" name. As Cameron mentioned, we
should probably just ditch the event from the proposal altogether.

Of course going down that path doesn't solve the issue I'm trying to solve
> which could be stated as
>
> *) Don't render from JS unless visible (ie, don't execute expensive 2d or
> 3d canvas rendering calls when not visible)
>

> With the caveats of
>
>   a) Make it extremely easy to do the right thing so that few if any sites
> making canvas ads or canvas games hog the CPU when not visible.
>   b) don't make the browser wait on JavaScript.
>   c) don't render more than needed. (ie, don't render 60 frames a second if
> you're only changing stuff at 15)
>

Those are good goals, except I think we need to drill down into (c). Are
people changing stuff at 15Hz for crude performance tuning, or for some
other reason?

Rob
-- 
"Now the Bereans were of more noble character than the Thessalonians, for
they received the message with great eagerness and examined the Scriptures
every day to see if what Paul said was true." [Acts 17:11]
Received on Thursday, 18 November 2010 01:20:43 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:42 GMT