Admittedly I haven't looked at precisely what jQuery does, other than to
verify that its animations do run on the main thread. requestAnimationFrame
doesn't solve the problem, though, because rAF callbacks run on the main
thread with full access to the DOM and JS heap. So if we tried to run them
concurrently with other main thread JS they'd race and crash.

A hypothetical requestAsyncAnimationFrame() API whose callback had no
general access to the DOM and window object (though you could, for example,
pass specific DOM objects in to mutate their styles) would solve this
issue. Google's old AnimationProxy proposal was similar, but the properties
it exposed were limited to those that Blink could animate in the
compositor, while Servo has no such limitation. CSS Houdini seems related
as well, since its custom layout module allows layout-related properties to
be changed from isolated JS contexts (i.e. JS contexts that would be safe
to run off the main thread).

Patrick
On Mar 21, 2015 11:50 AM, "Josh Matthews" <j...@joshmatthews.net> wrote:

> On 2015-03-21 2:27 PM, Patrick Walton wrote:
>
>> One remaining issue is how to deal with jQuery-style animations that are
>> done with setTimeout(). They have to contend with everything else on the
>> DOM/script thread to avoid breaking the HTML/JavaScript event loop
>> semantics. I've brainstormed ideas for doing some sort of fair scheduling
>> for events on the main thread to try to give animations priority wherever
>> possible, but anything like this still has to deal with the
>> run-to-completion for event handlers that hog the CPU. I'm open to ideas
>> here.
>>
>
> What are jQuery-style animations? Do they not use requestAnimationFrame?
> Will using that instead of setTimeout allow us to provide better guarantees
> to web developers?
>
> _______________________________________________
> dev-servo mailing list
> dev-servo@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-servo
>
_______________________________________________
dev-servo mailing list
dev-servo@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to