Bug 95360 - requestAnimationFrame broken with subframes (DisplayRefreshMonitorManager::registerClient fails to register client)
Summary: requestAnimationFrame broken with subframes (DisplayRefreshMonitorManager::re...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andrew Lo
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2012-08-29 11:02 PDT by Arvid Nilsson
Modified: 2012-09-27 20:15 PDT (History)
8 users (show)

See Also:


Attachments
RAF test (to be used in a subframe) (528 bytes, text/html)
2012-08-30 15:13 PDT, Simon Fraser (smfr)
no flags Details
Test with RAF in main document and iframe (785 bytes, text/html)
2012-08-30 15:14 PDT, Simon Fraser (smfr)
no flags Details
Patch (5.25 KB, patch)
2012-09-27 13:42 PDT, Andrew Lo
no flags Details | Formatted Diff | Diff
Patch (6.09 KB, patch)
2012-09-27 15:03 PDT, Andrew Lo
no flags Details | Formatted Diff | Diff
Patch (2.17 KB, patch)
2012-09-27 19:26 PDT, Andrew Lo
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Arvid Nilsson 2012-08-29 11:02:32 PDT
If there's already one client registered for a specific display ID, any further clients with that display ID will fail to be added, because registerClient only calls ensureMonitorForClient, which only adds the client to the monitor when creating it. If a monitor already existed, it will fail to add the new client and just return the existing monitor.
Comment 1 Simon Fraser (smfr) 2012-08-29 11:07:33 PDT
What are the user-visible effects of this bug?
Comment 2 Arvid Nilsson 2012-08-29 11:48:24 PDT
It looks to me like it would be a problem if you managed to get two ScriptedAnimationController instances to request animation frames. The second one would fail to register with the monitor.

I'll see if I can put together something that manages to do that (it may be impossible due to more high level mechanisms, not sure).

The reason I ran into this is not a specific bug, but development on a new feature for the BlackBerry port, perform accelerated compositing sync on a requestAnimationFrame instead of a 0-timeout timer. The idea is to service all the JS animations first, and then perform the AC sync last, to make sure their most recent animation changes become visible immediately.
Comment 3 Simon Fraser (smfr) 2012-08-29 11:52:56 PDT
So a page with an iframe, and both the parent and iframe doing RAF would see this?
Comment 4 Arvid Nilsson 2012-08-29 13:55:51 PDT
(In reply to comment #3)
> So a page with an iframe, and both the parent and iframe doing RAF would see this?

Yes, I'll try a frameset or iframe testcase as a reduction. So far, this is all in theory :)
Comment 5 Simon Fraser (smfr) 2012-08-30 15:13:17 PDT
Created attachment 161568 [details]
RAF test (to be used in a subframe)
Comment 6 Simon Fraser (smfr) 2012-08-30 15:14:11 PDT
Created attachment 161569 [details]
Test with RAF in main document and iframe
Comment 7 Simon Fraser (smfr) 2012-08-30 15:14:43 PDT
The attached second testcase certainly shows issues.
Comment 8 Simon Fraser (smfr) 2012-08-30 15:15:29 PDT
Safari also feels sluggish after loading these testcases.
Comment 9 Radar WebKit Bug Importer 2012-08-30 15:16:05 PDT
<rdar://problem/12210661>
Comment 10 Andrew Lo 2012-09-26 14:26:20 PDT
taking
Comment 11 Andrew Lo 2012-09-27 13:42:19 PDT
Created attachment 166058 [details]
Patch
Comment 12 Simon Fraser (smfr) 2012-09-27 13:58:19 PDT
Comment on attachment 166058 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166058&action=review

> LayoutTests/fast/animation/request-animation-frame-iframe2.html:23
> +        window.webkitRequestAnimationFrame(function() {
> +            mainFrameCallbackInvoked = true;
> +        }, e);

requestAnimationFrame() does not take an element parameter. That subframe JS should be fixed too.
Comment 13 Andrew Lo 2012-09-27 15:03:24 PDT
Created attachment 166069 [details]
Patch
Comment 14 WebKit Review Bot 2012-09-27 15:25:20 PDT
Comment on attachment 166069 [details]
Patch

Clearing flags on attachment: 166069

Committed r129808: <http://trac.webkit.org/changeset/129808>
Comment 15 WebKit Review Bot 2012-09-27 15:25:24 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Darin Adler 2012-09-27 16:43:27 PDT
Comment on attachment 166069 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166069&action=review

> Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp:83
> +    DisplayRefreshMonitorClientSet::iterator it = m_clients.find(client);
> +    if (it != m_clients.end())
> +        return;
> +
>      m_clients.add(client);

This change was not needed. The HashSet::add function already is guaranteed to safely do nothing if the pointer is already in the set.

Please roll this change out, since it all it does is add additional unnecessary code.

> Source/WebCore/platform/graphics/DisplayRefreshMonitor.cpp:143
> +    it->second.get()->addClient(client);

Should not need to explicitly call get() if we are going to use -> right afterward. Pleas omit the ".get()" here.
Comment 17 Andrew Lo 2012-09-27 19:26:40 PDT
Reopening to attach new patch.
Comment 18 Andrew Lo 2012-09-27 19:26:45 PDT
Created attachment 166118 [details]
Patch
Comment 19 WebKit Review Bot 2012-09-27 20:15:16 PDT
Comment on attachment 166118 [details]
Patch

Clearing flags on attachment: 166118

Committed r129842: <http://trac.webkit.org/changeset/129842>
Comment 20 WebKit Review Bot 2012-09-27 20:15:20 PDT
All reviewed patches have been landed.  Closing bug.