Chromium Code Reviews| Index: components/scheduler/renderer/renderer_scheduler_impl.cc |
| diff --git a/components/scheduler/renderer/renderer_scheduler_impl.cc b/components/scheduler/renderer/renderer_scheduler_impl.cc |
| index f241d7bb755b5c2ca1f66aeb42c9d38581ed7d3f..4873fd1d9761a126655ce98e4991aabc61954d10 100644 |
| --- a/components/scheduler/renderer/renderer_scheduler_impl.cc |
| +++ b/components/scheduler/renderer/renderer_scheduler_impl.cc |
| @@ -679,6 +679,13 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) { |
| MainThreadOnly().current_policy_expiration_time = base::TimeTicks(); |
| } |
| + // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely |
| + // slow, because that can cause starvation in other task sources. |
| + bool main_thread_compositing_is_fast = |
| + MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( |
| + MainThreadOnly().compositor_frame_interval) > |
| + base::TimeDelta::FromSeconds(0); |
|
alex clarke (OOO till 29th)
2016/05/03 09:47:01
As discussed off line I'm wondering if this might
Sami
2016/05/03 12:50:00
Yep, that's probably safer. Done.
|
| + |
| Policy new_policy; |
| ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; |
| switch (use_case) { |
| @@ -697,7 +704,9 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) { |
| break; |
| case UseCase::SYNCHRONIZED_GESTURE: |
| - new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| + new_policy.compositor_queue_policy.priority = |
| + main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY |
| + : TaskQueue::NORMAL_PRIORITY; |
| if (touchstart_expected_soon) { |
| expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| } else { |
| @@ -710,7 +719,9 @@ void RendererSchedulerImpl::UpdatePolicyLocked(UpdateType update_type) { |
| // things we should be prioritizing, so we don't attempt to block |
| // expensive tasks because we don't know whether they were integral to the |
| // page's functionality or not. |
| - new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| + new_policy.compositor_queue_policy.priority = |
| + main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY |
| + : TaskQueue::NORMAL_PRIORITY; |
| break; |
| case UseCase::TOUCHSTART: |