RE: [RequestAnimationFrame] requestAnimationFrame use in documents whose containing elements have no CSS box

IE10 fires the requestAnimationFrame callbacks even for a display:none styled iframe.

Seeing that this API has been designed for visual animations, not sure if firing the requestAnimationFrame callbacks on a display:none iframe makes sense - can you think of a use case where this would be useful? For time based animations, not firing the callbacks when the iframe is not visible will have no impact on the animation state when the iframe and animation become visible. Of course, frame based animations would be different - though, it isn't the recommended pattern for animations. Seems like a waste of CPU cycles to fire the callbacks in the display:none case. Thoughts?


From: James Robinson [mailto:jamesr@google.com]
Sent: Tuesday, January 03, 2012 10:36 AM
To: Boris Zbarsky
Cc: public-web-perf@w3.org
Subject: Re: [RequestAnimationFrame] requestAnimationFrame use in documents whose containing elements have no CSS box

On Thu, Dec 22, 2011 at 8:30 AM, Boris Zbarsky <bzbarsky@mit.edu<mailto:bzbarsky@mit.edu>> wrote:
Consider a testcase like this:

 <iframe style="display: none"
         src="some-document-using-requestAnimationFrame">
 </iframe>

I believe that right now Gecko will not run the animation frame callbacks for that subdocument.  I'm guessing that WebKit will run them, based on brief code inspection.  What does IE do?

The reason Gecko doesn't run them is that they're tied into the general "animation" infrastructure, which gets turned off in any situation in which styles cannot be computed.  And in documents whose viewport does not have a useful size (because the iframe has no CSS box at all), that's the case in Gecko.

That sounds like perfectly reasonable behavior.


The obvious questions are:

1)  Does the spec allow this behavior?

Currently, no.

2)  If not, should it?

I believe it should.

3)  Should it require it?  (This would take a bit of thinking to define; the definition of what Gecko does is above: no request callbacks in a document whose containing element has no CSS box; there may be some weirdness with svg:foreignObject kids having boxes even if the foreignObject is display:none, of course.)

I think it should but I'm not sure how to do so. It would surprise me if this concept is completely novel in the web platform, does nothing else need this?  If this is novel, could you propose some spec text?  The most obvious WebKit implementation would be based on a similar CSS box implementation construct.

As an aside, I had hoped that the hidden attribute from DocumentVisibility would define this but that's defined purely in terms of the top-level browsing context of the document.  It'd be nice if the property we use is something that authors can directly query.

- James



-Boris

Received on Wednesday, 4 January 2012 01:55:17 UTC