W3C home > Mailing lists > Public > public-web-perf@w3.org > May 2011

Re: [AnimationRequestFrame] Initial editor's draft of AnimationRequestFrame spec available

From: Robert O'Callahan <robert@ocallahan.org>
Date: Tue, 3 May 2011 18:05:47 +1200
Message-ID: <BANLkTi=wNwcK6Xa4giD_Q3T-pP1GAszj_w@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: James Robinson <jamesr@google.com>, public-web-perf@w3.org
On Tue, May 3, 2011 at 1:48 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> Robert, do you have any opinions here?  If you're not on this list, maybe
> you should be!
>

Another spec list? OK, my inbox runneth over!

I agree with James that we should guarantee that every element that's
visible when we paint should have had its animation callback(s) called. That
means some kind of potentially bad iteration is needed. On the other hand we
should NOT make any guarantees about callbacks not being called. So we would
be allowed to always call all of them if we want.

Then we can improve the iterative algorithm a bit by running callbacks as
soon as we think they are likely to be needed, like so:
1) Resample declarative animations
2) Run all animation callbacks with no associated element (we know these
need to run, best to run them first)
3) While there are callbacks that have not run yet:
  a) Flush restyles and layout
  b) Compute the set of callbacks that have not run yet whose elements are
currently visible in the viewport
  c) If that set is empty, go to step 4
  d) Otherwise, run all those callbacks
4) Flush restyles and layout
5) Paint

Then we'd only need multiple iterations of step 3 if an animation callback
actually makes another animated element visible. I would hope this is rare.
The tradeoff is that we might run an animation callback unnecessarily when
another animation callback has made the element invisible, but that should
also be rare.

Unfired callbacks need to stay in the list so that if the element becomes
visible, a callback fires. However, we can avoid wakeups by observing that
we only need to reschedule a scan of the list if a reflow or scroll
operation has occurred. Then for a page that's quiescent apart from an
animation callback for an element outside the viewport, we wouldn't wake up.

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 Tuesday, 3 May 2011 06:06:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 3 May 2011 06:06:15 GMT