[Webkit-unassigned] [Bug 100257] Don't fire requestAnimationFrame for scripts in frames that are out of view

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Oct 29 10:46:49 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=100257





--- Comment #9 from Nick Johnson <nick at spider.io>  2012-10-29 10:48:04 PST ---
(In reply to comment #8)
> (From update of attachment 171278 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=171278&action=review
> 
> > Source/WebCore/dom/ScriptedAnimationController.cpp:123
> > +    if (view && view->windowClipRect(false).isEmpty()) {
> > +        scheduleAnimation();
> > +        return;
> > +    }
> 
> Two things seem not quite right to me.
> 
> 1)  I don’t think that windowClipRect(false).isEmpty() is the correct visibility check; I can’t find any other code that’s using that and this can’t be the only place we care about visibility.

I spent a lot of time reading the code to try and understand the rendering process; I found windowClipRect in use in ScrollView::scrollContents to determine the visible part of the window. If there's a better method to use, I'm happy to change it; I just wasn't able to find a better choice myself.

> 2) I don’t think that polling is the right way to detect when the frame becomes visible again. We want to actively trigger it rather than running the timer over and over again.

I agree entirely, but based on my search of the code concerned with scrolling and rendering, there's currently nothing that triggers events when elements become visible or invisible, and no facility to trigger those events. Adding it would undoubtedly be possible, but I suspect it would be a significant and much higher impact (and risk) change.

The polling approach, while slightly messy, is an easy win - the timer is running repeatedly already, the patch simply avoids the expensive JavaScript callback when it's unnecessary - and seems unlikely to have unexpected side effects. In my experiments with content rendered in an iframe using requestAnimationFrame, CPU usage drops from anything up to 100% to effectively zero when the frame is scrolled offscreen.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the webkit-unassigned mailing list