requestIdleCallback delayed for up to 80ms before being started |
|||||
Issue descriptionThe attached test html file creates a series of requestIdleCallback to do some dummy work, and prints the total amount of time taken. rIC delays the finish time by between about 20-80ms compared to doing the same code in setTimeout even although no other work is being done to compete with the rIC callbacks. Taking a look at a trace (see attached), there is a 74ms pause between the first rIC being posted and it getting called, with the main thread doing nothing during this time. It appears that we are not in an idle period due to the BeginMainFrame@1440.828ms, and don't start a new idle period until the BeginMainFrameNotExpectedSoon@1517.664ms. Can the compositor be modified to send BeginMainFrameNotExpectedSoon sooner? Or could we at least trigger a set of short idle periods between the last BeginMainFrame and the BeginMainFrameNotExpectedSoon?
,
Jan 24 2017
Presumably because the compositor isn't sending BeginMainFrames / Commits during this period, so we don't trigger any short idle periods?
,
Jan 25 2017
Yeah, that's probably the reason. We could potentially change it to schedule short idle periods while no-one is requesting BeginMainFrames.
,
Jan 25 2017
,
Feb 3 2017
Discussed this with cc scheduler folks and the proposal is to add a "maybe not expecting BeginMainFrames soon" message which could start short idle periods in cases like this (plus others like impl-side animations).
,
Mar 7 2017
Who would be a good owner for this?
,
Mar 14 2017
Adding an infinite CSS animation permanently delays the idle callback so it never runs. (Unless you move the mouse in which case it will trigger).
E.g.
<style>
div {
width: 50px;
height: 50px;
background-color: red;
animation: 1s infinite alternate example;
}
/* Standard syntax */
@keyframes example {
0% {transform: translate(0px, 0px);}
100% {transform: translate(50px, 0px);}
}
</style>
<div></div>
,
Mar 14 2017
This is a composited CSS animation? That's definitely broken, though sounds like a separate bug.
,
Mar 14 2017
Sort of is and isn't -- in both cases the cc thread is receiving BeginFrames but not telling the main thread that it's idle.
,
Mar 14 2017
Ah, that makes sense. Thanks for the clarification.
,
May 5 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/9db74aa87f97c709baf5d38b82fb987713a40951 commit 9db74aa87f97c709baf5d38b82fb987713a40951 Author: delphick <delphick@chromium.org> Date: Fri May 05 10:20:49 2017 Create new action sent when a BeginMainFrame not expected before vsync. The renderer scheduler can then use this information to schedule short idle work as would have happened after a BeginMainFrame. This allows idle work to be scheduled for instance in cases where a compositor animation is occurring which prevents BeginMainFrameNotExpectedSoon from being sent. BUG= 683962 CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_trusty_blink_rel Review-Url: https://codereview.chromium.org/2753843003 Cr-Commit-Position: refs/heads/master@{#469619} [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/scheduler/scheduler.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/scheduler/scheduler.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/scheduler/scheduler_state_machine.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/scheduler/scheduler_state_machine.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/scheduler/scheduler_state_machine_unittest.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/scheduler/scheduler_unittest.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/test/layer_tree_test.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/test/stub_layer_tree_host_client.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/layer_tree_host.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/layer_tree_host.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/layer_tree_host_client.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/proxy_impl.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/proxy_impl.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/proxy_main.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/proxy_main.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/single_thread_proxy.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/cc/trees/single_thread_proxy.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/content/browser/renderer_host/compositor_impl_android.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/content/renderer/gpu/render_widget_compositor.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/content/renderer/gpu/render_widget_compositor.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/Source/platform/scheduler/renderer/renderer_scheduler_impl_unittest.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/Source/platform/scheduler/test/fake_renderer_scheduler.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/Source/platform/testing/WebLayerTreeViewImplForTesting.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/public/platform/scheduler/renderer/renderer_scheduler.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/public/platform/scheduler/test/fake_renderer_scheduler.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/third_party/WebKit/public/platform/scheduler/test/mock_renderer_scheduler.h [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/ui/compositor/compositor.cc [modify] https://crrev.com/9db74aa87f97c709baf5d38b82fb987713a40951/ui/compositor/compositor.h
,
May 5 2017
,
May 5 2017
This change completely fixes the compositor animation case above. It also improves the original test case, giving a lower bound of around 5ms overhead, but some runs still give results of over 40ms. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by skyos...@chromium.org
, Jan 24 2017