| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h" | 5 #include "components/scheduler/renderer/renderer_scheduler_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/stack_trace.h" | 8 #include "base/debug/stack_trace.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "base/trace_event/trace_event_argument.h" | 10 #include "base/trace_event/trace_event_argument.h" |
| 11 #include "cc/output/begin_frame_args.h" | 11 #include "cc/output/begin_frame_args.h" |
| 12 #include "components/scheduler/base/task_queue_impl.h" | 12 #include "components/scheduler/base/task_queue_impl.h" |
| 13 #include "components/scheduler/base/task_queue_selector.h" | 13 #include "components/scheduler/base/task_queue_selector.h" |
| 14 #include "components/scheduler/child/scheduler_task_runner_delegate.h" | 14 #include "components/scheduler/child/scheduler_task_runner_delegate.h" |
| 15 | 15 |
| 16 namespace scheduler { | 16 namespace scheduler { |
| 17 namespace { | 17 namespace { |
| 18 const int kLoadingTaskEstimationSampleCount = 200; | 18 const int kLoadingTaskEstimationSampleCount = 200; |
| 19 const double kLoadingTaskEstimationPercentile = 90; | 19 const double kLoadingTaskEstimationPercentile = 90; |
| 20 const int kTimerTaskEstimationSampleCount = 200; | 20 const int kTimerTaskEstimationSampleCount = 200; |
| 21 const double kTimerTaskEstimationPercentile = 90; | 21 const double kTimerTaskEstimationPercentile = 90; |
| 22 const int kShortIdlePeriodDurationSampleCount = 10; | 22 const int kShortIdlePeriodDurationSampleCount = 10; |
| 23 const double kShortIdlePeriodDurationPercentile = 20; | 23 const double kShortIdlePeriodDurationPercentile = 50; |
| 24 } | 24 } |
| 25 | 25 |
| 26 RendererSchedulerImpl::RendererSchedulerImpl( | 26 RendererSchedulerImpl::RendererSchedulerImpl( |
| 27 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner) | 27 scoped_refptr<SchedulerTaskRunnerDelegate> main_task_runner) |
| 28 : helper_(main_task_runner, | 28 : helper_(main_task_runner, |
| 29 "renderer.scheduler", | 29 "renderer.scheduler", |
| 30 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 30 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 31 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), | 31 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler.debug")), |
| 32 idle_helper_(&helper_, | 32 idle_helper_(&helper_, |
| 33 this, | 33 this, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( | 50 end_renderer_hidden_idle_period_closure_.Reset(base::Bind( |
| 51 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); | 51 &RendererSchedulerImpl::EndIdlePeriod, weak_factory_.GetWeakPtr())); |
| 52 | 52 |
| 53 suspend_timers_when_backgrounded_closure_.Reset( | 53 suspend_timers_when_backgrounded_closure_.Reset( |
| 54 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, | 54 base::Bind(&RendererSchedulerImpl::SuspendTimerQueueWhenBackgrounded, |
| 55 weak_factory_.GetWeakPtr())); | 55 weak_factory_.GetWeakPtr())); |
| 56 | 56 |
| 57 default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq"); | 57 default_loading_task_runner_ = NewLoadingTaskRunner("default_loading_tq"); |
| 58 default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq"); | 58 default_timer_task_runner_ = NewTimerTaskRunner("default_timer_tq"); |
| 59 | 59 |
| 60 compositor_task_runner_->AddTaskObserver( |
| 61 &MainThreadOnly().idle_time_estimator); |
| 62 |
| 60 TRACE_EVENT_OBJECT_CREATED_WITH_ID( | 63 TRACE_EVENT_OBJECT_CREATED_WITH_ID( |
| 61 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 64 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
| 62 this); | 65 this); |
| 63 | 66 |
| 64 // Make sure that we don't initially assume there is no idle time. | |
| 65 MainThreadOnly().short_idle_period_duration.InsertSample( | |
| 66 cc::BeginFrameArgs::DefaultInterval()); | |
| 67 | |
| 68 helper_.SetObserver(this); | 67 helper_.SetObserver(this); |
| 69 } | 68 } |
| 70 | 69 |
| 71 RendererSchedulerImpl::~RendererSchedulerImpl() { | 70 RendererSchedulerImpl::~RendererSchedulerImpl() { |
| 72 TRACE_EVENT_OBJECT_DELETED_WITH_ID( | 71 TRACE_EVENT_OBJECT_DELETED_WITH_ID( |
| 73 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 72 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
| 74 this); | 73 this); |
| 75 | 74 |
| 76 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { | 75 for (const scoped_refptr<TaskQueue>& loading_queue : loading_task_runners_) { |
| 77 loading_queue->RemoveTaskObserver( | 76 loading_queue->RemoveTaskObserver( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 : compositor_queue_priority(TaskQueue::NORMAL_PRIORITY), | 91 : compositor_queue_priority(TaskQueue::NORMAL_PRIORITY), |
| 93 loading_queue_priority(TaskQueue::NORMAL_PRIORITY), | 92 loading_queue_priority(TaskQueue::NORMAL_PRIORITY), |
| 94 timer_queue_priority(TaskQueue::NORMAL_PRIORITY), | 93 timer_queue_priority(TaskQueue::NORMAL_PRIORITY), |
| 95 default_queue_priority(TaskQueue::NORMAL_PRIORITY) {} | 94 default_queue_priority(TaskQueue::NORMAL_PRIORITY) {} |
| 96 | 95 |
| 97 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly() | 96 RendererSchedulerImpl::MainThreadOnly::MainThreadOnly() |
| 98 : loading_task_cost_estimator(kLoadingTaskEstimationSampleCount, | 97 : loading_task_cost_estimator(kLoadingTaskEstimationSampleCount, |
| 99 kLoadingTaskEstimationPercentile), | 98 kLoadingTaskEstimationPercentile), |
| 100 timer_task_cost_estimator(kTimerTaskEstimationSampleCount, | 99 timer_task_cost_estimator(kTimerTaskEstimationSampleCount, |
| 101 kTimerTaskEstimationPercentile), | 100 kTimerTaskEstimationPercentile), |
| 102 short_idle_period_duration(kShortIdlePeriodDurationSampleCount), | 101 idle_time_estimator(kShortIdlePeriodDurationSampleCount, |
| 102 kShortIdlePeriodDurationPercentile), |
| 103 current_use_case(UseCase::NONE), | 103 current_use_case(UseCase::NONE), |
| 104 timer_queue_suspend_count(0), | 104 timer_queue_suspend_count(0), |
| 105 navigation_task_expected_count(0), | 105 navigation_task_expected_count(0), |
| 106 renderer_hidden(false), | 106 renderer_hidden(false), |
| 107 renderer_backgrounded(false), | 107 renderer_backgrounded(false), |
| 108 timer_queue_suspension_when_backgrounded_enabled(false), | 108 timer_queue_suspension_when_backgrounded_enabled(false), |
| 109 timer_queue_suspended_when_backgrounded(false), | 109 timer_queue_suspended_when_backgrounded(false), |
| 110 was_shutdown(false), | 110 was_shutdown(false), |
| 111 loading_tasks_seem_expensive(false), | 111 loading_tasks_seem_expensive(false), |
| 112 timer_tasks_seem_expensive(false), | 112 timer_tasks_seem_expensive(false), |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 void RendererSchedulerImpl::WillBeginFrame(const cc::BeginFrameArgs& args) { | 213 void RendererSchedulerImpl::WillBeginFrame(const cc::BeginFrameArgs& args) { |
| 214 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 214 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 215 "RendererSchedulerImpl::WillBeginFrame", "args", args.AsValue()); | 215 "RendererSchedulerImpl::WillBeginFrame", "args", args.AsValue()); |
| 216 helper_.CheckOnValidThread(); | 216 helper_.CheckOnValidThread(); |
| 217 if (helper_.IsShutdown()) | 217 if (helper_.IsShutdown()) |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 EndIdlePeriod(); | 220 EndIdlePeriod(); |
| 221 MainThreadOnly().estimated_next_frame_begin = args.frame_time + args.interval; | 221 MainThreadOnly().estimated_next_frame_begin = args.frame_time + args.interval; |
| 222 MainThreadOnly().have_seen_a_begin_main_frame = true; | 222 MainThreadOnly().have_seen_a_begin_main_frame = true; |
| 223 MainThreadOnly().compositor_frame_interval = args.interval; |
| 223 { | 224 { |
| 224 base::AutoLock lock(any_thread_lock_); | 225 base::AutoLock lock(any_thread_lock_); |
| 225 AnyThread().begin_main_frame_on_critical_path = args.on_critical_path; | 226 AnyThread().begin_main_frame_on_critical_path = args.on_critical_path; |
| 226 } | 227 } |
| 227 } | 228 } |
| 228 | 229 |
| 229 void RendererSchedulerImpl::DidCommitFrameToCompositor() { | 230 void RendererSchedulerImpl::DidCommitFrameToCompositor() { |
| 230 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 231 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 231 "RendererSchedulerImpl::DidCommitFrameToCompositor"); | 232 "RendererSchedulerImpl::DidCommitFrameToCompositor"); |
| 232 helper_.CheckOnValidThread(); | 233 helper_.CheckOnValidThread(); |
| 233 if (helper_.IsShutdown()) | 234 if (helper_.IsShutdown()) |
| 234 return; | 235 return; |
| 235 | 236 |
| 236 base::TimeTicks now(helper_.Now()); | 237 base::TimeTicks now(helper_.Now()); |
| 237 if (now < MainThreadOnly().estimated_next_frame_begin) { | 238 if (now < MainThreadOnly().estimated_next_frame_begin) { |
| 238 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of | 239 // TODO(rmcilroy): Consider reducing the idle period based on the runtime of |
| 239 // the next pending delayed tasks (as currently done in for long idle times) | 240 // the next pending delayed tasks (as currently done in for long idle times) |
| 240 idle_helper_.StartIdlePeriod( | 241 idle_helper_.StartIdlePeriod( |
| 241 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, | 242 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, now, |
| 242 MainThreadOnly().estimated_next_frame_begin); | 243 MainThreadOnly().estimated_next_frame_begin); |
| 243 MainThreadOnly().short_idle_period_duration.InsertSample( | |
| 244 MainThreadOnly().estimated_next_frame_begin - now); | |
| 245 } else { | |
| 246 // There was no idle time :( | |
| 247 MainThreadOnly().short_idle_period_duration.InsertSample(base::TimeDelta()); | |
| 248 } | 244 } |
| 249 | 245 |
| 250 MainThreadOnly().expected_short_idle_period_duration = | 246 MainThreadOnly().idle_time_estimator.DidCommitFrameToCompositor(); |
| 251 MainThreadOnly().short_idle_period_duration.Percentile( | |
| 252 kShortIdlePeriodDurationPercentile); | |
| 253 } | 247 } |
| 254 | 248 |
| 255 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { | 249 void RendererSchedulerImpl::BeginFrameNotExpectedSoon() { |
| 256 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 250 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 257 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); | 251 "RendererSchedulerImpl::BeginFrameNotExpectedSoon"); |
| 258 helper_.CheckOnValidThread(); | 252 helper_.CheckOnValidThread(); |
| 259 if (helper_.IsShutdown()) | 253 if (helper_.IsShutdown()) |
| 260 return; | 254 return; |
| 261 | 255 |
| 262 idle_helper_.EnableLongIdlePeriod(); | 256 idle_helper_.EnableLongIdlePeriod(); |
| 257 { |
| 258 base::AutoLock lock(any_thread_lock_); |
| 259 AnyThread().begin_main_frame_on_critical_path = false; |
| 260 } |
| 263 } | 261 } |
| 264 | 262 |
| 265 void RendererSchedulerImpl::OnRendererHidden() { | 263 void RendererSchedulerImpl::OnRendererHidden() { |
| 266 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 264 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 267 "RendererSchedulerImpl::OnRendererHidden"); | 265 "RendererSchedulerImpl::OnRendererHidden"); |
| 268 helper_.CheckOnValidThread(); | 266 helper_.CheckOnValidThread(); |
| 269 if (helper_.IsShutdown() || MainThreadOnly().renderer_hidden) | 267 if (helper_.IsShutdown() || MainThreadOnly().renderer_hidden) |
| 270 return; | 268 return; |
| 271 | 269 |
| 272 idle_helper_.EnableLongIdlePeriod(); | 270 idle_helper_.EnableLongIdlePeriod(); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 550 |
| 553 // TODO(alexclarke): We should wire up a signal from blink to let us know if | 551 // TODO(alexclarke): We should wire up a signal from blink to let us know if |
| 554 // there are any touch handlers registerd or not, and only call | 552 // there are any touch handlers registerd or not, and only call |
| 555 // TouchStartExpectedSoon if there is at least one. NOTE a TouchStart will | 553 // TouchStartExpectedSoon if there is at least one. NOTE a TouchStart will |
| 556 // only actually get sent if there is a touch handler. | 554 // only actually get sent if there is a touch handler. |
| 557 base::TimeDelta touchstart_expected_flag_valid_for_duration; | 555 base::TimeDelta touchstart_expected_flag_valid_for_duration; |
| 558 bool touchstart_expected_soon = AnyThread().user_model.IsGestureExpectedSoon( | 556 bool touchstart_expected_soon = AnyThread().user_model.IsGestureExpectedSoon( |
| 559 use_case, now, &touchstart_expected_flag_valid_for_duration); | 557 use_case, now, &touchstart_expected_flag_valid_for_duration); |
| 560 MainThreadOnly().touchstart_expected_soon = touchstart_expected_soon; | 558 MainThreadOnly().touchstart_expected_soon = touchstart_expected_soon; |
| 561 | 559 |
| 560 // In UseCase::MAIN_THREAD_GESTURE we want to make sure the idle time |
| 561 // estimation is based upon hitting the compositor set framerate. In other |
| 562 // uses cases we want to try and meet the rails response time. |
| 563 base::TimeDelta expected_idle_duration = |
| 564 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( |
| 565 use_case == UseCase::MAIN_THREAD_GESTURE |
| 566 ? MainThreadOnly().compositor_frame_interval |
| 567 : base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis)); |
| 568 MainThreadOnly().expected_idle_duration = expected_idle_duration; |
| 569 |
| 562 bool loading_tasks_seem_expensive = | 570 bool loading_tasks_seem_expensive = |
| 563 MainThreadOnly().loading_task_cost_estimator.expected_task_duration() > | 571 MainThreadOnly().loading_task_cost_estimator.expected_task_duration() > |
| 564 MainThreadOnly().expected_short_idle_period_duration; | 572 expected_idle_duration; |
| 565 MainThreadOnly().loading_tasks_seem_expensive = loading_tasks_seem_expensive; | 573 MainThreadOnly().loading_tasks_seem_expensive = loading_tasks_seem_expensive; |
| 566 | 574 |
| 567 bool timer_tasks_seem_expensive = | 575 bool timer_tasks_seem_expensive = |
| 568 MainThreadOnly().timer_task_cost_estimator.expected_task_duration() > | 576 MainThreadOnly().timer_task_cost_estimator.expected_task_duration() > |
| 569 MainThreadOnly().expected_short_idle_period_duration; | 577 expected_idle_duration; |
| 570 MainThreadOnly().timer_tasks_seem_expensive = timer_tasks_seem_expensive; | 578 MainThreadOnly().timer_tasks_seem_expensive = timer_tasks_seem_expensive; |
| 571 | 579 |
| 572 // The |new_policy_duration| is the minimum of |expected_use_case_duration| | 580 // The |new_policy_duration| is the minimum of |expected_use_case_duration| |
| 573 // and |touchstart_expected_flag_valid_for_duration| unless one is zero in | 581 // and |touchstart_expected_flag_valid_for_duration| unless one is zero in |
| 574 // which case we choose the other. | 582 // which case we choose the other. |
| 575 base::TimeDelta new_policy_duration = expected_use_case_duration; | 583 base::TimeDelta new_policy_duration = expected_use_case_duration; |
| 576 if (new_policy_duration == base::TimeDelta() || | 584 if (new_policy_duration == base::TimeDelta() || |
| 577 (touchstart_expected_flag_valid_for_duration > base::TimeDelta() && | 585 (touchstart_expected_flag_valid_for_duration > base::TimeDelta() && |
| 578 new_policy_duration > touchstart_expected_flag_valid_for_duration)) { | 586 new_policy_duration > touchstart_expected_flag_valid_for_duration)) { |
| 579 new_policy_duration = touchstart_expected_flag_valid_for_duration; | 587 new_policy_duration = touchstart_expected_flag_valid_for_duration; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 if (!MainThreadOnly().have_seen_a_begin_main_frame) | 640 if (!MainThreadOnly().have_seen_a_begin_main_frame) |
| 633 block_expensive_tasks = false; | 641 block_expensive_tasks = false; |
| 634 | 642 |
| 635 // Don't block expensive tasks if we are expecting a navigation. | 643 // Don't block expensive tasks if we are expecting a navigation. |
| 636 if (MainThreadOnly().navigation_task_expected_count > 0) | 644 if (MainThreadOnly().navigation_task_expected_count > 0) |
| 637 block_expensive_tasks = false; | 645 block_expensive_tasks = false; |
| 638 | 646 |
| 639 if (block_expensive_tasks && loading_tasks_seem_expensive) | 647 if (block_expensive_tasks && loading_tasks_seem_expensive) |
| 640 new_policy.loading_queue_priority = TaskQueue::DISABLED_PRIORITY; | 648 new_policy.loading_queue_priority = TaskQueue::DISABLED_PRIORITY; |
| 641 | 649 |
| 642 if (MainThreadOnly().timer_queue_suspend_count != 0 || | 650 if ((block_expensive_tasks && timer_tasks_seem_expensive) || |
| 651 MainThreadOnly().timer_queue_suspend_count != 0 || |
| 643 MainThreadOnly().timer_queue_suspended_when_backgrounded) { | 652 MainThreadOnly().timer_queue_suspended_when_backgrounded) { |
| 644 new_policy.timer_queue_priority = TaskQueue::DISABLED_PRIORITY; | 653 new_policy.timer_queue_priority = TaskQueue::DISABLED_PRIORITY; |
| 645 } | 654 } |
| 646 | 655 |
| 647 // Tracing is done before the early out check, because it's quite possible we | 656 // Tracing is done before the early out check, because it's quite possible we |
| 648 // will otherwise miss this information in traces. | 657 // will otherwise miss this information in traces. |
| 649 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 658 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
| 650 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 659 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
| 651 this, AsValueLocked(now)); | 660 this, AsValueLocked(now)); |
| 652 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", | 661 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 TaskCostEstimator* | 760 TaskCostEstimator* |
| 752 RendererSchedulerImpl::GetLoadingTaskCostEstimatorForTesting() { | 761 RendererSchedulerImpl::GetLoadingTaskCostEstimatorForTesting() { |
| 753 return &MainThreadOnly().loading_task_cost_estimator; | 762 return &MainThreadOnly().loading_task_cost_estimator; |
| 754 } | 763 } |
| 755 | 764 |
| 756 TaskCostEstimator* | 765 TaskCostEstimator* |
| 757 RendererSchedulerImpl::GetTimerTaskCostEstimatorForTesting() { | 766 RendererSchedulerImpl::GetTimerTaskCostEstimatorForTesting() { |
| 758 return &MainThreadOnly().timer_task_cost_estimator; | 767 return &MainThreadOnly().timer_task_cost_estimator; |
| 759 } | 768 } |
| 760 | 769 |
| 770 IdleTimeEstimator* RendererSchedulerImpl::GetIdleTimeEstimatorForTesting() { |
| 771 return &MainThreadOnly().idle_time_estimator; |
| 772 } |
| 773 |
| 761 void RendererSchedulerImpl::SuspendTimerQueue() { | 774 void RendererSchedulerImpl::SuspendTimerQueue() { |
| 762 MainThreadOnly().timer_queue_suspend_count++; | 775 MainThreadOnly().timer_queue_suspend_count++; |
| 763 ForceUpdatePolicy(); | 776 ForceUpdatePolicy(); |
| 764 #ifndef NDEBUG | 777 #ifndef NDEBUG |
| 765 DCHECK(!default_timer_task_runner_->IsQueueEnabled()); | 778 DCHECK(!default_timer_task_runner_->IsQueueEnabled()); |
| 766 for (const auto& runner : timer_task_runners_) { | 779 for (const auto& runner : timer_task_runners_) { |
| 767 DCHECK(!runner->IsQueueEnabled()); | 780 DCHECK(!runner->IsQueueEnabled()); |
| 768 } | 781 } |
| 769 #endif | 782 #endif |
| 770 } | 783 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 AnyThread().begin_main_frame_on_critical_path); | 844 AnyThread().begin_main_frame_on_critical_path); |
| 832 state->SetDouble("expected_loading_task_duration", | 845 state->SetDouble("expected_loading_task_duration", |
| 833 MainThreadOnly() | 846 MainThreadOnly() |
| 834 .loading_task_cost_estimator.expected_task_duration() | 847 .loading_task_cost_estimator.expected_task_duration() |
| 835 .InMillisecondsF()); | 848 .InMillisecondsF()); |
| 836 state->SetDouble("expected_timer_task_duration", | 849 state->SetDouble("expected_timer_task_duration", |
| 837 MainThreadOnly() | 850 MainThreadOnly() |
| 838 .timer_task_cost_estimator.expected_task_duration() | 851 .timer_task_cost_estimator.expected_task_duration() |
| 839 .InMillisecondsF()); | 852 .InMillisecondsF()); |
| 840 // TODO(skyostil): Can we somehow trace how accurate these estimates were? | 853 // TODO(skyostil): Can we somehow trace how accurate these estimates were? |
| 854 state->SetDouble("expected_idle_duration", |
| 855 MainThreadOnly().expected_idle_duration.InMillisecondsF()); |
| 841 state->SetDouble( | 856 state->SetDouble( |
| 842 "expected_short_idle_period_duration", | 857 "compositor_frame_interval", |
| 843 MainThreadOnly().expected_short_idle_period_duration.InMillisecondsF()); | 858 MainThreadOnly().compositor_frame_interval.InMillisecondsF()); |
| 844 state->SetDouble( | 859 state->SetDouble( |
| 845 "estimated_next_frame_begin", | 860 "estimated_next_frame_begin", |
| 846 (MainThreadOnly().estimated_next_frame_begin - base::TimeTicks()) | 861 (MainThreadOnly().estimated_next_frame_begin - base::TimeTicks()) |
| 847 .InMillisecondsF()); | 862 .InMillisecondsF()); |
| 848 state->SetBoolean("in_idle_period", AnyThread().in_idle_period); | 863 state->SetBoolean("in_idle_period", AnyThread().in_idle_period); |
| 849 AnyThread().user_model.AsValueInto(state.get()); | 864 AnyThread().user_model.AsValueInto(state.get()); |
| 850 | 865 |
| 851 return state; | 866 return state; |
| 852 } | 867 } |
| 853 | 868 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 | 925 |
| 911 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; | 926 MainThreadOnly().timer_queue_suspended_when_backgrounded = false; |
| 912 ForceUpdatePolicy(); | 927 ForceUpdatePolicy(); |
| 913 } | 928 } |
| 914 | 929 |
| 915 void RendererSchedulerImpl::ResetForNavigationLocked() { | 930 void RendererSchedulerImpl::ResetForNavigationLocked() { |
| 916 helper_.CheckOnValidThread(); | 931 helper_.CheckOnValidThread(); |
| 917 any_thread_lock_.AssertAcquired(); | 932 any_thread_lock_.AssertAcquired(); |
| 918 MainThreadOnly().loading_task_cost_estimator.Clear(); | 933 MainThreadOnly().loading_task_cost_estimator.Clear(); |
| 919 MainThreadOnly().timer_task_cost_estimator.Clear(); | 934 MainThreadOnly().timer_task_cost_estimator.Clear(); |
| 920 MainThreadOnly().short_idle_period_duration.Clear(); | 935 MainThreadOnly().idle_time_estimator.Clear(); |
| 921 // Make sure that we don't initially assume there is no idle time. | |
| 922 MainThreadOnly().short_idle_period_duration.InsertSample( | |
| 923 cc::BeginFrameArgs::DefaultInterval()); | |
| 924 AnyThread().user_model.Reset(helper_.Now()); | 936 AnyThread().user_model.Reset(helper_.Now()); |
| 925 MainThreadOnly().have_seen_a_begin_main_frame = false; | 937 MainThreadOnly().have_seen_a_begin_main_frame = false; |
| 926 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); | 938 UpdatePolicyLocked(UpdateType::MAY_EARLY_OUT_IF_POLICY_UNCHANGED); |
| 927 } | 939 } |
| 928 | 940 |
| 929 } // namespace scheduler | 941 } // namespace scheduler |
| OLD | NEW |