New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 683962 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: May 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

requestIdleCallback delayed for up to 80ms before being started

Project Member Reported by rmcilroy@chromium.org, Jan 23 2017

Issue description

The 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?
 
rIC_test.html
904 bytes View Download
rIC_delay.png
105 KB View Download
trace_rIC_delay.json.gz
930 KB Download
Cc: briander...@chromium.org
We might be able to tweak the compositor to stop rendering sooner, although the risk is that we'll regress input latency in some cases where we should've kept rendering.

In this example it seems like we should've seen short idle periods in this window. Any idea why that isn't happening?
Presumably because the compositor isn't sending BeginMainFrames / Commits during this period, so we don't trigger any short idle periods?
Status: Available (was: Untriaged)
Yeah, that's probably the reason. We could potentially change it to schedule short idle periods while no-one is requesting BeginMainFrames.
Cc: aerotwist@chromium.org rmcilroy@chromium.org
 Issue 565396  has been merged into this issue.
Cc: delph...@chromium.org
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).
Who would be a good owner for this?
Owner: delph...@chromium.org
Status: Assigned (was: Available)
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>

This is a composited CSS animation?

That's definitely broken, though sounds like a separate bug.
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.
Ah, that makes sense. Thanks for the clarification.
Project Member

Comment 11 by bugdroid1@chromium.org, 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

Status: Fixed (was: Assigned)
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