Chromium Code Reviews| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 was_shutdown(false), | 125 was_shutdown(false), |
| 126 loading_tasks_seem_expensive(false), | 126 loading_tasks_seem_expensive(false), |
| 127 timer_tasks_seem_expensive(false), | 127 timer_tasks_seem_expensive(false), |
| 128 touchstart_expected_soon(false), | 128 touchstart_expected_soon(false), |
| 129 have_seen_a_begin_main_frame(false), | 129 have_seen_a_begin_main_frame(false), |
| 130 have_reported_blocking_intervention_in_current_policy(false), | 130 have_reported_blocking_intervention_in_current_policy(false), |
| 131 have_reported_blocking_intervention_since_navigation(false), | 131 have_reported_blocking_intervention_since_navigation(false), |
| 132 has_visible_render_widget_with_touch_handler(false), | 132 has_visible_render_widget_with_touch_handler(false), |
| 133 begin_frame_not_expected_soon(false), | 133 begin_frame_not_expected_soon(false), |
| 134 expensive_task_blocking_allowed(true), | 134 expensive_task_blocking_allowed(true), |
| 135 in_idle_period_for_testing(false) {} | 135 in_idle_period_for_testing(false), |
| 136 rail_mode_observer(nullptr) {} | |
| 136 | 137 |
| 137 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {} | 138 RendererSchedulerImpl::MainThreadOnly::~MainThreadOnly() {} |
| 138 | 139 |
| 139 RendererSchedulerImpl::AnyThread::AnyThread() | 140 RendererSchedulerImpl::AnyThread::AnyThread() |
| 140 : awaiting_touch_start_response(false), | 141 : awaiting_touch_start_response(false), |
| 141 in_idle_period(false), | 142 in_idle_period(false), |
| 142 begin_main_frame_on_critical_path(false), | 143 begin_main_frame_on_critical_path(false), |
| 143 last_gesture_was_compositor_driven(false), | 144 last_gesture_was_compositor_driven(false), |
| 144 default_gesture_prevented(true), | 145 default_gesture_prevented(true), |
| 145 have_seen_touchstart(false) {} | 146 have_seen_touchstart(false) {} |
| 146 | 147 |
| 147 RendererSchedulerImpl::AnyThread::~AnyThread() {} | 148 RendererSchedulerImpl::AnyThread::~AnyThread() {} |
| 148 | 149 |
| 149 RendererSchedulerImpl::CompositorThreadOnly::CompositorThreadOnly() | 150 RendererSchedulerImpl::CompositorThreadOnly::CompositorThreadOnly() |
| 150 : last_input_type(blink::WebInputEvent::Undefined) {} | 151 : last_input_type(blink::WebInputEvent::Undefined) {} |
| 151 | 152 |
| 152 RendererSchedulerImpl::CompositorThreadOnly::~CompositorThreadOnly() {} | 153 RendererSchedulerImpl::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 153 | 154 |
| 154 void RendererSchedulerImpl::Shutdown() { | 155 void RendererSchedulerImpl::Shutdown() { |
| 155 throttling_helper_.reset(); | 156 throttling_helper_.reset(); |
| 156 helper_.Shutdown(); | 157 helper_.Shutdown(); |
| 157 MainThreadOnly().was_shutdown = true; | 158 MainThreadOnly().was_shutdown = true; |
| 159 MainThreadOnly().rail_mode_observer = nullptr; | |
| 158 } | 160 } |
| 159 | 161 |
| 160 std::unique_ptr<blink::WebThread> RendererSchedulerImpl::CreateMainThread() { | 162 std::unique_ptr<blink::WebThread> RendererSchedulerImpl::CreateMainThread() { |
| 161 return base::WrapUnique(new WebThreadImplForRendererScheduler(this)); | 163 return base::WrapUnique(new WebThreadImplForRendererScheduler(this)); |
| 162 } | 164 } |
| 163 | 165 |
| 164 scoped_refptr<TaskQueue> RendererSchedulerImpl::DefaultTaskRunner() { | 166 scoped_refptr<TaskQueue> RendererSchedulerImpl::DefaultTaskRunner() { |
| 165 return helper_.DefaultTaskRunner(); | 167 return helper_.DefaultTaskRunner(); |
| 166 } | 168 } |
| 167 | 169 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely | 726 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely |
| 725 // slow, because that can cause starvation in other task sources. | 727 // slow, because that can cause starvation in other task sources. |
| 726 bool main_thread_compositing_is_fast = | 728 bool main_thread_compositing_is_fast = |
| 727 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( | 729 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( |
| 728 MainThreadOnly().compositor_frame_interval) > | 730 MainThreadOnly().compositor_frame_interval) > |
| 729 MainThreadOnly().compositor_frame_interval * | 731 MainThreadOnly().compositor_frame_interval * |
| 730 kFastCompositingIdleTimeThreshold; | 732 kFastCompositingIdleTimeThreshold; |
| 731 | 733 |
| 732 Policy new_policy; | 734 Policy new_policy; |
| 733 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; | 735 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; |
| 736 | |
| 737 if (MainThreadOnly().begin_frame_not_expected_soon) | |
| 738 new_policy.rail_mode = v8::PERFORMANCE_DEFAULT; | |
|
ulan
2016/06/28 13:09:08
Looks like we will never get idle mode in foregrou
rmcilroy
2016/06/28 13:16:34
Sami and I chatted a bit about this. Are you sure
ulan
2016/06/28 13:30:43
Indeed, idle defined as "page goes inactive" would
Sami
2016/06/28 13:53:18
It shouldn't be too difficult, but we just have to
ulan
2016/06/28 14:47:25
Thank you! Related note: we discussed DEFAULT mode
Sami
2016/06/28 15:01:37
Right, I was wondering about the difference betwee
| |
| 739 else | |
| 740 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION; | |
| 741 | |
| 734 switch (use_case) { | 742 switch (use_case) { |
| 735 case UseCase::COMPOSITOR_GESTURE: | 743 case UseCase::COMPOSITOR_GESTURE: |
| 736 if (touchstart_expected_soon) { | 744 if (touchstart_expected_soon) { |
| 745 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE; | |
| 737 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 746 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 738 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 747 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 739 } else { | 748 } else { |
| 740 // What we really want to do is priorize loading tasks, but that doesn't | 749 // What we really want to do is priorize loading tasks, but that doesn't |
| 741 // seem to be safe. Instead we do that by proxy by deprioritizing | 750 // seem to be safe. Instead we do that by proxy by deprioritizing |
| 742 // compositor tasks. This should be safe since we've already gone to the | 751 // compositor tasks. This should be safe since we've already gone to the |
| 743 // pain of fixing ordering issues with them. | 752 // pain of fixing ordering issues with them. |
| 744 new_policy.compositor_queue_policy.priority = | 753 new_policy.compositor_queue_policy.priority = |
| 745 TaskQueue::BEST_EFFORT_PRIORITY; | 754 TaskQueue::BEST_EFFORT_PRIORITY; |
| 746 } | 755 } |
| 747 break; | 756 break; |
| 748 | 757 |
| 749 case UseCase::SYNCHRONIZED_GESTURE: | 758 case UseCase::SYNCHRONIZED_GESTURE: |
| 750 new_policy.compositor_queue_policy.priority = | 759 new_policy.compositor_queue_policy.priority = |
| 751 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY | 760 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY |
| 752 : TaskQueue::NORMAL_PRIORITY; | 761 : TaskQueue::NORMAL_PRIORITY; |
| 753 if (touchstart_expected_soon) { | 762 if (touchstart_expected_soon) { |
| 763 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE; | |
| 754 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 764 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 755 } else { | 765 } else { |
| 766 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION; | |
| 756 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; | 767 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; |
| 757 } | 768 } |
| 758 break; | 769 break; |
| 759 | 770 |
| 760 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: | 771 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: |
| 761 // In main thread input handling scenarios we don't have perfect knowledge | 772 // In main thread input handling scenarios we don't have perfect knowledge |
| 762 // about which things we should be prioritizing, so we don't attempt to | 773 // about which things we should be prioritizing, so we don't attempt to |
| 763 // block expensive tasks because we don't know whether they were integral | 774 // block expensive tasks because we don't know whether they were integral |
| 764 // to the page's functionality or not. | 775 // to the page's functionality or not. |
| 776 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION; | |
| 765 new_policy.compositor_queue_policy.priority = | 777 new_policy.compositor_queue_policy.priority = |
| 766 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY | 778 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY |
| 767 : TaskQueue::NORMAL_PRIORITY; | 779 : TaskQueue::NORMAL_PRIORITY; |
| 768 break; | 780 break; |
| 769 | 781 |
| 770 case UseCase::MAIN_THREAD_GESTURE: | 782 case UseCase::MAIN_THREAD_GESTURE: |
| 771 // A main thread gesture is for example a scroll gesture which is handled | 783 // A main thread gesture is for example a scroll gesture which is handled |
| 772 // by the main thread. Since we know the established gesture type, we can | 784 // by the main thread. Since we know the established gesture type, we can |
| 773 // be a little more aggressive about prioritizing compositing and input | 785 // be a little more aggressive about prioritizing compositing and input |
| 774 // handling over other tasks. | 786 // handling over other tasks. |
| 775 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 787 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 776 if (touchstart_expected_soon) { | 788 if (touchstart_expected_soon) { |
| 789 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE; | |
| 777 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 790 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 778 } else { | 791 } else { |
| 792 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION; | |
| 779 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; | 793 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; |
| 780 } | 794 } |
| 781 break; | 795 break; |
| 782 | 796 |
| 783 case UseCase::TOUCHSTART: | 797 case UseCase::TOUCHSTART: |
| 798 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE; | |
| 784 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 799 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 785 new_policy.loading_queue_policy.is_enabled = false; | 800 new_policy.loading_queue_policy.is_enabled = false; |
| 786 new_policy.timer_queue_policy.is_enabled = false; | 801 new_policy.timer_queue_policy.is_enabled = false; |
| 787 // NOTE this is a nop due to the above. | 802 // NOTE this is a nop due to the above. |
| 788 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 803 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 789 break; | 804 break; |
| 790 | 805 |
| 791 case UseCase::NONE: | 806 case UseCase::NONE: |
| 792 // It's only safe to block tasks that if we are expecting a compositor | 807 // It's only safe to block tasks that if we are expecting a compositor |
| 793 // driven gesture. | 808 // driven gesture. |
| 794 if (touchstart_expected_soon && | 809 if (touchstart_expected_soon && |
| 795 AnyThread().last_gesture_was_compositor_driven) { | 810 AnyThread().last_gesture_was_compositor_driven) { |
| 811 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE; | |
| 796 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 812 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 797 } | 813 } |
| 798 break; | 814 break; |
| 799 | 815 |
| 800 case UseCase::LOADING: | 816 case UseCase::LOADING: |
| 817 new_policy.rail_mode = v8::PERFORMANCE_LOAD; | |
|
ulan
2016/06/28 13:09:08
The CL description says "A future patch will add s
Sami
2016/06/28 13:53:18
Yes, we currently don't enter the loading use case
| |
| 801 new_policy.loading_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 818 new_policy.loading_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 802 new_policy.default_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 819 new_policy.default_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 803 break; | 820 break; |
| 804 | 821 |
| 805 default: | 822 default: |
| 806 NOTREACHED(); | 823 NOTREACHED(); |
| 807 } | 824 } |
| 808 | 825 |
| 826 if (MainThreadOnly().renderer_hidden) | |
| 827 new_policy.rail_mode = v8::PERFORMANCE_IDLE; | |
| 828 | |
| 809 if (expensive_task_policy == ExpensiveTaskPolicy::BLOCK && | 829 if (expensive_task_policy == ExpensiveTaskPolicy::BLOCK && |
| 810 (!MainThreadOnly().expensive_task_blocking_allowed || | 830 (!MainThreadOnly().expensive_task_blocking_allowed || |
| 811 !MainThreadOnly().have_seen_a_begin_main_frame || | 831 !MainThreadOnly().have_seen_a_begin_main_frame || |
| 812 MainThreadOnly().navigation_task_expected_count > 0)) { | 832 MainThreadOnly().navigation_task_expected_count > 0)) { |
| 813 expensive_task_policy = ExpensiveTaskPolicy::RUN; | 833 expensive_task_policy = ExpensiveTaskPolicy::RUN; |
| 814 } | 834 } |
| 815 | 835 |
| 816 switch (expensive_task_policy) { | 836 switch (expensive_task_policy) { |
| 817 case ExpensiveTaskPolicy::RUN: | 837 case ExpensiveTaskPolicy::RUN: |
| 818 break; | 838 break; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 849 DCHECK(!new_policy.timer_queue_policy.is_enabled); | 869 DCHECK(!new_policy.timer_queue_policy.is_enabled); |
| 850 } | 870 } |
| 851 | 871 |
| 852 // Tracing is done before the early out check, because it's quite possible we | 872 // Tracing is done before the early out check, because it's quite possible we |
| 853 // will otherwise miss this information in traces. | 873 // will otherwise miss this information in traces. |
| 854 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 874 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
| 855 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", | 875 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", |
| 856 this, AsValueLocked(now)); | 876 this, AsValueLocked(now)); |
| 857 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", | 877 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", |
| 858 use_case); | 878 use_case); |
| 879 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "rail_mode", | |
| 880 new_policy.rail_mode); | |
| 859 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 881 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 860 "touchstart_expected_soon", | 882 "touchstart_expected_soon", |
| 861 MainThreadOnly().touchstart_expected_soon); | 883 MainThreadOnly().touchstart_expected_soon); |
| 862 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 884 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 863 "expensive_task_policy", expensive_task_policy); | 885 "expensive_task_policy", expensive_task_policy); |
| 864 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 886 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 865 "RendererScheduler.loading_tasks_seem_expensive", | 887 "RendererScheduler.loading_tasks_seem_expensive", |
| 866 MainThreadOnly().loading_tasks_seem_expensive); | 888 MainThreadOnly().loading_tasks_seem_expensive); |
| 867 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), | 889 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), |
| 868 "RendererScheduler.timer_tasks_seem_expensive", | 890 "RendererScheduler.timer_tasks_seem_expensive", |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 891 } | 913 } |
| 892 MainThreadOnly().have_reported_blocking_intervention_in_current_policy = | 914 MainThreadOnly().have_reported_blocking_intervention_in_current_policy = |
| 893 false; | 915 false; |
| 894 | 916 |
| 895 // TODO(alexclarke): We shouldn't have to prioritize the default queue, but it | 917 // TODO(alexclarke): We shouldn't have to prioritize the default queue, but it |
| 896 // appears to be necessary since the order of loading tasks and IPCs (which | 918 // appears to be necessary since the order of loading tasks and IPCs (which |
| 897 // are mostly dispatched on the default queue) need to be preserved. | 919 // are mostly dispatched on the default queue) need to be preserved. |
| 898 ApplyTaskQueuePolicy(helper_.DefaultTaskRunner().get(), | 920 ApplyTaskQueuePolicy(helper_.DefaultTaskRunner().get(), |
| 899 MainThreadOnly().current_policy.default_queue_policy, | 921 MainThreadOnly().current_policy.default_queue_policy, |
| 900 new_policy.default_queue_policy); | 922 new_policy.default_queue_policy); |
| 923 if (MainThreadOnly().rail_mode_observer && | |
| 924 new_policy.rail_mode != MainThreadOnly().current_policy.rail_mode) { | |
| 925 MainThreadOnly().rail_mode_observer->OnRAILModeChanged( | |
| 926 new_policy.rail_mode); | |
| 927 } | |
| 901 | 928 |
| 902 DCHECK(compositor_task_runner_->IsQueueEnabled()); | 929 DCHECK(compositor_task_runner_->IsQueueEnabled()); |
| 903 MainThreadOnly().current_policy = new_policy; | 930 MainThreadOnly().current_policy = new_policy; |
| 904 } | 931 } |
| 905 | 932 |
| 906 void RendererSchedulerImpl::ApplyTaskQueuePolicy( | 933 void RendererSchedulerImpl::ApplyTaskQueuePolicy( |
| 907 TaskQueue* task_queue, | 934 TaskQueue* task_queue, |
| 908 const TaskQueuePolicy& old_task_queue_policy, | 935 const TaskQueuePolicy& old_task_queue_policy, |
| 909 const TaskQueuePolicy& new_task_queue_policy) const { | 936 const TaskQueuePolicy& new_task_queue_policy) const { |
| 910 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) { | 937 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1087 | 1114 |
| 1088 if (optional_now.is_null()) | 1115 if (optional_now.is_null()) |
| 1089 optional_now = helper_.scheduler_tqm_delegate()->NowTicks(); | 1116 optional_now = helper_.scheduler_tqm_delegate()->NowTicks(); |
| 1090 std::unique_ptr<base::trace_event::TracedValue> state( | 1117 std::unique_ptr<base::trace_event::TracedValue> state( |
| 1091 new base::trace_event::TracedValue()); | 1118 new base::trace_event::TracedValue()); |
| 1092 state->SetBoolean( | 1119 state->SetBoolean( |
| 1093 "has_visible_render_widget_with_touch_handler", | 1120 "has_visible_render_widget_with_touch_handler", |
| 1094 MainThreadOnly().has_visible_render_widget_with_touch_handler); | 1121 MainThreadOnly().has_visible_render_widget_with_touch_handler); |
| 1095 state->SetString("current_use_case", | 1122 state->SetString("current_use_case", |
| 1096 UseCaseToString(MainThreadOnly().current_use_case)); | 1123 UseCaseToString(MainThreadOnly().current_use_case)); |
| 1124 state->SetString("rail_mode", | |
| 1125 RAILModeToString(MainThreadOnly().current_policy.rail_mode)); | |
| 1097 state->SetBoolean("expensive_task_blocking_allowed", | 1126 state->SetBoolean("expensive_task_blocking_allowed", |
| 1098 MainThreadOnly().expensive_task_blocking_allowed); | 1127 MainThreadOnly().expensive_task_blocking_allowed); |
| 1099 state->SetBoolean("loading_tasks_seem_expensive", | 1128 state->SetBoolean("loading_tasks_seem_expensive", |
| 1100 MainThreadOnly().loading_tasks_seem_expensive); | 1129 MainThreadOnly().loading_tasks_seem_expensive); |
| 1101 state->SetBoolean("timer_tasks_seem_expensive", | 1130 state->SetBoolean("timer_tasks_seem_expensive", |
| 1102 MainThreadOnly().timer_tasks_seem_expensive); | 1131 MainThreadOnly().timer_tasks_seem_expensive); |
| 1103 state->SetBoolean("begin_frame_not_expected_soon", | 1132 state->SetBoolean("begin_frame_not_expected_soon", |
| 1104 MainThreadOnly().begin_frame_not_expected_soon); | 1133 MainThreadOnly().begin_frame_not_expected_soon); |
| 1105 state->SetBoolean("touchstart_expected_soon", | 1134 state->SetBoolean("touchstart_expected_soon", |
| 1106 MainThreadOnly().touchstart_expected_soon); | 1135 MainThreadOnly().touchstart_expected_soon); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 // Per-frame task runners (loading, timers, etc.) are configured with a more | 1295 // Per-frame task runners (loading, timers, etc.) are configured with a more |
| 1267 // specific blame context by WebFrameSchedulerImpl. | 1296 // specific blame context by WebFrameSchedulerImpl. |
| 1268 control_task_runner_->SetBlameContext(blame_context); | 1297 control_task_runner_->SetBlameContext(blame_context); |
| 1269 DefaultTaskRunner()->SetBlameContext(blame_context); | 1298 DefaultTaskRunner()->SetBlameContext(blame_context); |
| 1270 default_loading_task_runner_->SetBlameContext(blame_context); | 1299 default_loading_task_runner_->SetBlameContext(blame_context); |
| 1271 default_timer_task_runner_->SetBlameContext(blame_context); | 1300 default_timer_task_runner_->SetBlameContext(blame_context); |
| 1272 compositor_task_runner_->SetBlameContext(blame_context); | 1301 compositor_task_runner_->SetBlameContext(blame_context); |
| 1273 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); | 1302 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); |
| 1274 } | 1303 } |
| 1275 | 1304 |
| 1305 void RendererSchedulerImpl::SetRAILModeObserver(RAILModeObserver* observer) { | |
| 1306 MainThreadOnly().rail_mode_observer = observer; | |
| 1307 } | |
| 1308 | |
| 1276 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) { | 1309 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) { |
| 1277 helper_.RegisterTimeDomain(time_domain); | 1310 helper_.RegisterTimeDomain(time_domain); |
| 1278 } | 1311 } |
| 1279 | 1312 |
| 1280 void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) { | 1313 void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) { |
| 1281 helper_.UnregisterTimeDomain(time_domain); | 1314 helper_.UnregisterTimeDomain(time_domain); |
| 1282 } | 1315 } |
| 1283 | 1316 |
| 1284 void RendererSchedulerImpl::SetExpensiveTaskBlockingAllowed(bool allowed) { | 1317 void RendererSchedulerImpl::SetExpensiveTaskBlockingAllowed(bool allowed) { |
| 1285 MainThreadOnly().expensive_task_blocking_allowed = allowed; | 1318 MainThreadOnly().expensive_task_blocking_allowed = allowed; |
| 1286 } | 1319 } |
| 1287 | 1320 |
| 1288 base::TickClock* RendererSchedulerImpl::tick_clock() const { | 1321 base::TickClock* RendererSchedulerImpl::tick_clock() const { |
| 1289 return helper_.scheduler_tqm_delegate().get(); | 1322 return helper_.scheduler_tqm_delegate().get(); |
| 1290 } | 1323 } |
| 1291 | 1324 |
| 1292 void RendererSchedulerImpl::AddWebViewScheduler( | 1325 void RendererSchedulerImpl::AddWebViewScheduler( |
| 1293 WebViewSchedulerImpl* web_view_scheduler) { | 1326 WebViewSchedulerImpl* web_view_scheduler) { |
| 1294 MainThreadOnly().web_view_schedulers_.insert(web_view_scheduler); | 1327 MainThreadOnly().web_view_schedulers.insert(web_view_scheduler); |
| 1295 } | 1328 } |
| 1296 | 1329 |
| 1297 void RendererSchedulerImpl::RemoveWebViewScheduler( | 1330 void RendererSchedulerImpl::RemoveWebViewScheduler( |
| 1298 WebViewSchedulerImpl* web_view_scheduler) { | 1331 WebViewSchedulerImpl* web_view_scheduler) { |
| 1299 DCHECK(MainThreadOnly().web_view_schedulers_.find(web_view_scheduler) != | 1332 DCHECK(MainThreadOnly().web_view_schedulers.find(web_view_scheduler) != |
| 1300 MainThreadOnly().web_view_schedulers_.end()); | 1333 MainThreadOnly().web_view_schedulers.end()); |
| 1301 MainThreadOnly().web_view_schedulers_.erase(web_view_scheduler); | 1334 MainThreadOnly().web_view_schedulers.erase(web_view_scheduler); |
| 1302 } | 1335 } |
| 1303 | 1336 |
| 1304 void RendererSchedulerImpl::BroadcastConsoleWarning( | 1337 void RendererSchedulerImpl::BroadcastConsoleWarning( |
| 1305 const std::string& message) { | 1338 const std::string& message) { |
| 1306 helper_.CheckOnValidThread(); | 1339 helper_.CheckOnValidThread(); |
| 1307 for (auto& web_view_scheduler : MainThreadOnly().web_view_schedulers_) | 1340 for (auto& web_view_scheduler : MainThreadOnly().web_view_schedulers) |
| 1308 web_view_scheduler->AddConsoleWarning(message); | 1341 web_view_scheduler->AddConsoleWarning(message); |
| 1309 } | 1342 } |
| 1310 | 1343 |
| 1311 void RendererSchedulerImpl::OnTriedToExecuteBlockedTask( | 1344 void RendererSchedulerImpl::OnTriedToExecuteBlockedTask( |
| 1312 const TaskQueue& queue, | 1345 const TaskQueue& queue, |
| 1313 const base::PendingTask& task) { | 1346 const base::PendingTask& task) { |
| 1314 if (!MainThreadOnly().expensive_task_blocking_allowed || | 1347 if (!MainThreadOnly().expensive_task_blocking_allowed || |
| 1315 MainThreadOnly().current_use_case == UseCase::TOUCHSTART || | 1348 MainThreadOnly().current_use_case == UseCase::TOUCHSTART || |
| 1316 MainThreadOnly().longest_jank_free_task_duration < | 1349 MainThreadOnly().longest_jank_free_task_duration < |
| 1317 base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis) || | 1350 base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis) || |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 1341 true; | 1374 true; |
| 1342 BroadcastConsoleWarning( | 1375 BroadcastConsoleWarning( |
| 1343 "Blink deferred a task in order to make scrolling smoother. " | 1376 "Blink deferred a task in order to make scrolling smoother. " |
| 1344 "Your timer and network tasks should take less than 50ms to run " | 1377 "Your timer and network tasks should take less than 50ms to run " |
| 1345 "to avoid this. Please see " | 1378 "to avoid this. Please see " |
| 1346 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" | 1379 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" |
| 1347 " and https://crbug.com/574343#c40 for more information."); | 1380 " and https://crbug.com/574343#c40 for more information."); |
| 1348 } | 1381 } |
| 1349 } | 1382 } |
| 1350 | 1383 |
| 1384 // static | |
| 1385 const char* RendererSchedulerImpl::UseCaseToString(UseCase use_case) { | |
| 1386 switch (use_case) { | |
| 1387 case UseCase::NONE: | |
| 1388 return "none"; | |
| 1389 case UseCase::COMPOSITOR_GESTURE: | |
| 1390 return "compositor_gesture"; | |
| 1391 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: | |
| 1392 return "main_thread_custom_input_handling"; | |
| 1393 case UseCase::SYNCHRONIZED_GESTURE: | |
| 1394 return "synchronized_gesture"; | |
| 1395 case UseCase::TOUCHSTART: | |
| 1396 return "touchstart"; | |
| 1397 case UseCase::LOADING: | |
| 1398 return "loading"; | |
| 1399 case UseCase::MAIN_THREAD_GESTURE: | |
| 1400 return "main_thread_gesture"; | |
| 1401 default: | |
| 1402 NOTREACHED(); | |
| 1403 return nullptr; | |
| 1404 } | |
| 1405 } | |
| 1406 | |
| 1407 // static | |
| 1408 const char* RendererSchedulerImpl::RAILModeToString(v8::RAILMode rail_mode) { | |
| 1409 switch (rail_mode) { | |
| 1410 case v8::PERFORMANCE_DEFAULT: | |
| 1411 return "default"; | |
| 1412 case v8::PERFORMANCE_RESPONSE: | |
| 1413 return "response"; | |
| 1414 case v8::PERFORMANCE_ANIMATION: | |
| 1415 return "animation"; | |
| 1416 case v8::PERFORMANCE_IDLE: | |
| 1417 return "idle"; | |
| 1418 case v8::PERFORMANCE_LOAD: | |
| 1419 return "load"; | |
| 1420 default: | |
| 1421 NOTREACHED(); | |
| 1422 return nullptr; | |
| 1423 } | |
| 1424 } | |
| 1425 | |
| 1351 } // namespace scheduler | 1426 } // namespace scheduler |
| OLD | NEW |