Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: components/scheduler/renderer/renderer_scheduler_impl.cc

Issue 2093983002: scheduler: Tell v8 about the current RAIL mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 isolate(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) {}
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely 725 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely
725 // slow, because that can cause starvation in other task sources. 726 // slow, because that can cause starvation in other task sources.
726 bool main_thread_compositing_is_fast = 727 bool main_thread_compositing_is_fast =
727 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( 728 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration(
728 MainThreadOnly().compositor_frame_interval) > 729 MainThreadOnly().compositor_frame_interval) >
729 MainThreadOnly().compositor_frame_interval * 730 MainThreadOnly().compositor_frame_interval *
730 kFastCompositingIdleTimeThreshold; 731 kFastCompositingIdleTimeThreshold;
731 732
732 Policy new_policy; 733 Policy new_policy;
733 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; 734 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN;
735
736 if (MainThreadOnly().begin_frame_not_expected_soon)
737 new_policy.rail_mode = v8::PERFORMANCE_DEFAULT;
738 else
739 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION;
740
734 switch (use_case) { 741 switch (use_case) {
735 case UseCase::COMPOSITOR_GESTURE: 742 case UseCase::COMPOSITOR_GESTURE:
736 if (touchstart_expected_soon) { 743 if (touchstart_expected_soon) {
744 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
737 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 745 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
738 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 746 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
739 } else { 747 } else {
740 // What we really want to do is priorize loading tasks, but that doesn't 748 // 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 749 // 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 750 // compositor tasks. This should be safe since we've already gone to the
743 // pain of fixing ordering issues with them. 751 // pain of fixing ordering issues with them.
744 new_policy.compositor_queue_policy.priority = 752 new_policy.compositor_queue_policy.priority =
745 TaskQueue::BEST_EFFORT_PRIORITY; 753 TaskQueue::BEST_EFFORT_PRIORITY;
746 } 754 }
747 break; 755 break;
748 756
749 case UseCase::SYNCHRONIZED_GESTURE: 757 case UseCase::SYNCHRONIZED_GESTURE:
750 new_policy.compositor_queue_policy.priority = 758 new_policy.compositor_queue_policy.priority =
751 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY 759 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY
752 : TaskQueue::NORMAL_PRIORITY; 760 : TaskQueue::NORMAL_PRIORITY;
753 if (touchstart_expected_soon) { 761 if (touchstart_expected_soon) {
762 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
754 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 763 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
755 } else { 764 } else {
765 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION;
756 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; 766 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE;
757 } 767 }
758 break; 768 break;
759 769
760 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING: 770 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING:
761 // In main thread input handling scenarios we don't have perfect knowledge 771 // 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 772 // 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 773 // block expensive tasks because we don't know whether they were integral
764 // to the page's functionality or not. 774 // to the page's functionality or not.
775 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION;
765 new_policy.compositor_queue_policy.priority = 776 new_policy.compositor_queue_policy.priority =
766 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY 777 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY
767 : TaskQueue::NORMAL_PRIORITY; 778 : TaskQueue::NORMAL_PRIORITY;
768 break; 779 break;
769 780
770 case UseCase::MAIN_THREAD_GESTURE: 781 case UseCase::MAIN_THREAD_GESTURE:
771 // A main thread gesture is for example a scroll gesture which is handled 782 // 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 783 // by the main thread. Since we know the established gesture type, we can
773 // be a little more aggressive about prioritizing compositing and input 784 // be a little more aggressive about prioritizing compositing and input
774 // handling over other tasks. 785 // handling over other tasks.
775 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 786 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
776 if (touchstart_expected_soon) { 787 if (touchstart_expected_soon) {
788 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
777 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 789 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
778 } else { 790 } else {
791 new_policy.rail_mode = v8::PERFORMANCE_ANIMATION;
779 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; 792 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE;
780 } 793 }
781 break; 794 break;
782 795
783 case UseCase::TOUCHSTART: 796 case UseCase::TOUCHSTART:
797 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
784 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 798 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
785 new_policy.loading_queue_policy.is_enabled = false; 799 new_policy.loading_queue_policy.is_enabled = false;
786 new_policy.timer_queue_policy.is_enabled = false; 800 new_policy.timer_queue_policy.is_enabled = false;
787 // NOTE this is a nop due to the above. 801 // NOTE this is a nop due to the above.
788 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 802 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
789 break; 803 break;
790 804
791 case UseCase::NONE: 805 case UseCase::NONE:
792 // It's only safe to block tasks that if we are expecting a compositor 806 // It's only safe to block tasks that if we are expecting a compositor
793 // driven gesture. 807 // driven gesture.
794 if (touchstart_expected_soon && 808 if (touchstart_expected_soon &&
795 AnyThread().last_gesture_was_compositor_driven) { 809 AnyThread().last_gesture_was_compositor_driven) {
810 new_policy.rail_mode = v8::PERFORMANCE_RESPONSE;
796 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; 811 expensive_task_policy = ExpensiveTaskPolicy::BLOCK;
797 } 812 }
798 break; 813 break;
799 814
800 case UseCase::LOADING: 815 case UseCase::LOADING:
816 new_policy.rail_mode = v8::PERFORMANCE_LOAD;
801 new_policy.loading_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 817 new_policy.loading_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
802 new_policy.default_queue_policy.priority = TaskQueue::HIGH_PRIORITY; 818 new_policy.default_queue_policy.priority = TaskQueue::HIGH_PRIORITY;
803 break; 819 break;
804 820
805 default: 821 default:
806 NOTREACHED(); 822 NOTREACHED();
807 } 823 }
808 824
825 if (MainThreadOnly().renderer_hidden)
826 new_policy.rail_mode = v8::PERFORMANCE_IDLE;
827
809 if (expensive_task_policy == ExpensiveTaskPolicy::BLOCK && 828 if (expensive_task_policy == ExpensiveTaskPolicy::BLOCK &&
810 (!MainThreadOnly().expensive_task_blocking_allowed || 829 (!MainThreadOnly().expensive_task_blocking_allowed ||
811 !MainThreadOnly().have_seen_a_begin_main_frame || 830 !MainThreadOnly().have_seen_a_begin_main_frame ||
812 MainThreadOnly().navigation_task_expected_count > 0)) { 831 MainThreadOnly().navigation_task_expected_count > 0)) {
813 expensive_task_policy = ExpensiveTaskPolicy::RUN; 832 expensive_task_policy = ExpensiveTaskPolicy::RUN;
814 } 833 }
815 834
816 switch (expensive_task_policy) { 835 switch (expensive_task_policy) {
817 case ExpensiveTaskPolicy::RUN: 836 case ExpensiveTaskPolicy::RUN:
818 break; 837 break;
(...skipping 30 matching lines...) Expand all
849 DCHECK(!new_policy.timer_queue_policy.is_enabled); 868 DCHECK(!new_policy.timer_queue_policy.is_enabled);
850 } 869 }
851 870
852 // Tracing is done before the early out check, because it's quite possible we 871 // Tracing is done before the early out check, because it's quite possible we
853 // will otherwise miss this information in traces. 872 // will otherwise miss this information in traces.
854 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( 873 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(
855 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler", 874 TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "RendererScheduler",
856 this, AsValueLocked(now)); 875 this, AsValueLocked(now));
857 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case", 876 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "use_case",
858 use_case); 877 use_case);
878 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), "rail_mode",
879 new_policy.rail_mode);
859 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 880 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
860 "touchstart_expected_soon", 881 "touchstart_expected_soon",
861 MainThreadOnly().touchstart_expected_soon); 882 MainThreadOnly().touchstart_expected_soon);
862 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 883 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
863 "expensive_task_policy", expensive_task_policy); 884 "expensive_task_policy", expensive_task_policy);
864 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 885 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
865 "RendererScheduler.loading_tasks_seem_expensive", 886 "RendererScheduler.loading_tasks_seem_expensive",
866 MainThreadOnly().loading_tasks_seem_expensive); 887 MainThreadOnly().loading_tasks_seem_expensive);
867 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"), 888 TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("renderer.scheduler"),
868 "RendererScheduler.timer_tasks_seem_expensive", 889 "RendererScheduler.timer_tasks_seem_expensive",
(...skipping 22 matching lines...) Expand all
891 } 912 }
892 MainThreadOnly().have_reported_blocking_intervention_in_current_policy = 913 MainThreadOnly().have_reported_blocking_intervention_in_current_policy =
893 false; 914 false;
894 915
895 // TODO(alexclarke): We shouldn't have to prioritize the default queue, but it 916 // 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 917 // 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. 918 // are mostly dispatched on the default queue) need to be preserved.
898 ApplyTaskQueuePolicy(helper_.DefaultTaskRunner().get(), 919 ApplyTaskQueuePolicy(helper_.DefaultTaskRunner().get(),
899 MainThreadOnly().current_policy.default_queue_policy, 920 MainThreadOnly().current_policy.default_queue_policy,
900 new_policy.default_queue_policy); 921 new_policy.default_queue_policy);
922 if (MainThreadOnly().isolate &&
923 new_policy.rail_mode != MainThreadOnly().current_policy.rail_mode) {
924 MainThreadOnly().isolate->SetRAILMode(new_policy.rail_mode);
925 }
901 926
902 DCHECK(compositor_task_runner_->IsQueueEnabled()); 927 DCHECK(compositor_task_runner_->IsQueueEnabled());
903 MainThreadOnly().current_policy = new_policy; 928 MainThreadOnly().current_policy = new_policy;
904 } 929 }
905 930
906 void RendererSchedulerImpl::ApplyTaskQueuePolicy( 931 void RendererSchedulerImpl::ApplyTaskQueuePolicy(
907 TaskQueue* task_queue, 932 TaskQueue* task_queue,
908 const TaskQueuePolicy& old_task_queue_policy, 933 const TaskQueuePolicy& old_task_queue_policy,
909 const TaskQueuePolicy& new_task_queue_policy) const { 934 const TaskQueuePolicy& new_task_queue_policy) const {
910 if (old_task_queue_policy.is_enabled != new_task_queue_policy.is_enabled) { 935 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
1087 1112
1088 if (optional_now.is_null()) 1113 if (optional_now.is_null())
1089 optional_now = helper_.scheduler_tqm_delegate()->NowTicks(); 1114 optional_now = helper_.scheduler_tqm_delegate()->NowTicks();
1090 std::unique_ptr<base::trace_event::TracedValue> state( 1115 std::unique_ptr<base::trace_event::TracedValue> state(
1091 new base::trace_event::TracedValue()); 1116 new base::trace_event::TracedValue());
1092 state->SetBoolean( 1117 state->SetBoolean(
1093 "has_visible_render_widget_with_touch_handler", 1118 "has_visible_render_widget_with_touch_handler",
1094 MainThreadOnly().has_visible_render_widget_with_touch_handler); 1119 MainThreadOnly().has_visible_render_widget_with_touch_handler);
1095 state->SetString("current_use_case", 1120 state->SetString("current_use_case",
1096 UseCaseToString(MainThreadOnly().current_use_case)); 1121 UseCaseToString(MainThreadOnly().current_use_case));
1122 state->SetString("rail_mode",
1123 RAILModeToString(MainThreadOnly().current_policy.rail_mode));
1097 state->SetBoolean("expensive_task_blocking_allowed", 1124 state->SetBoolean("expensive_task_blocking_allowed",
1098 MainThreadOnly().expensive_task_blocking_allowed); 1125 MainThreadOnly().expensive_task_blocking_allowed);
1099 state->SetBoolean("loading_tasks_seem_expensive", 1126 state->SetBoolean("loading_tasks_seem_expensive",
1100 MainThreadOnly().loading_tasks_seem_expensive); 1127 MainThreadOnly().loading_tasks_seem_expensive);
1101 state->SetBoolean("timer_tasks_seem_expensive", 1128 state->SetBoolean("timer_tasks_seem_expensive",
1102 MainThreadOnly().timer_tasks_seem_expensive); 1129 MainThreadOnly().timer_tasks_seem_expensive);
1103 state->SetBoolean("begin_frame_not_expected_soon", 1130 state->SetBoolean("begin_frame_not_expected_soon",
1104 MainThreadOnly().begin_frame_not_expected_soon); 1131 MainThreadOnly().begin_frame_not_expected_soon);
1105 state->SetBoolean("touchstart_expected_soon", 1132 state->SetBoolean("touchstart_expected_soon",
1106 MainThreadOnly().touchstart_expected_soon); 1133 MainThreadOnly().touchstart_expected_soon);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 // Per-frame task runners (loading, timers, etc.) are configured with a more 1293 // Per-frame task runners (loading, timers, etc.) are configured with a more
1267 // specific blame context by WebFrameSchedulerImpl. 1294 // specific blame context by WebFrameSchedulerImpl.
1268 control_task_runner_->SetBlameContext(blame_context); 1295 control_task_runner_->SetBlameContext(blame_context);
1269 DefaultTaskRunner()->SetBlameContext(blame_context); 1296 DefaultTaskRunner()->SetBlameContext(blame_context);
1270 default_loading_task_runner_->SetBlameContext(blame_context); 1297 default_loading_task_runner_->SetBlameContext(blame_context);
1271 default_timer_task_runner_->SetBlameContext(blame_context); 1298 default_timer_task_runner_->SetBlameContext(blame_context);
1272 compositor_task_runner_->SetBlameContext(blame_context); 1299 compositor_task_runner_->SetBlameContext(blame_context);
1273 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context); 1300 idle_helper_.IdleTaskRunner()->SetBlameContext(blame_context);
1274 } 1301 }
1275 1302
1303 void RendererSchedulerImpl::SetMainThreadIsolate(v8::Isolate* isolate) {
1304 MainThreadOnly().isolate = isolate;
1305 }
1306
1276 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) { 1307 void RendererSchedulerImpl::RegisterTimeDomain(TimeDomain* time_domain) {
1277 helper_.RegisterTimeDomain(time_domain); 1308 helper_.RegisterTimeDomain(time_domain);
1278 } 1309 }
1279 1310
1280 void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) { 1311 void RendererSchedulerImpl::UnregisterTimeDomain(TimeDomain* time_domain) {
1281 helper_.UnregisterTimeDomain(time_domain); 1312 helper_.UnregisterTimeDomain(time_domain);
1282 } 1313 }
1283 1314
1284 void RendererSchedulerImpl::SetExpensiveTaskBlockingAllowed(bool allowed) { 1315 void RendererSchedulerImpl::SetExpensiveTaskBlockingAllowed(bool allowed) {
1285 MainThreadOnly().expensive_task_blocking_allowed = allowed; 1316 MainThreadOnly().expensive_task_blocking_allowed = allowed;
1286 } 1317 }
1287 1318
1288 base::TickClock* RendererSchedulerImpl::tick_clock() const { 1319 base::TickClock* RendererSchedulerImpl::tick_clock() const {
1289 return helper_.scheduler_tqm_delegate().get(); 1320 return helper_.scheduler_tqm_delegate().get();
1290 } 1321 }
1291 1322
1292 void RendererSchedulerImpl::AddWebViewScheduler( 1323 void RendererSchedulerImpl::AddWebViewScheduler(
1293 WebViewSchedulerImpl* web_view_scheduler) { 1324 WebViewSchedulerImpl* web_view_scheduler) {
1294 MainThreadOnly().web_view_schedulers_.insert(web_view_scheduler); 1325 MainThreadOnly().web_view_schedulers.insert(web_view_scheduler);
1295 } 1326 }
1296 1327
1297 void RendererSchedulerImpl::RemoveWebViewScheduler( 1328 void RendererSchedulerImpl::RemoveWebViewScheduler(
1298 WebViewSchedulerImpl* web_view_scheduler) { 1329 WebViewSchedulerImpl* web_view_scheduler) {
1299 DCHECK(MainThreadOnly().web_view_schedulers_.find(web_view_scheduler) != 1330 DCHECK(MainThreadOnly().web_view_schedulers.find(web_view_scheduler) !=
1300 MainThreadOnly().web_view_schedulers_.end()); 1331 MainThreadOnly().web_view_schedulers.end());
1301 MainThreadOnly().web_view_schedulers_.erase(web_view_scheduler); 1332 MainThreadOnly().web_view_schedulers.erase(web_view_scheduler);
1302 } 1333 }
1303 1334
1304 void RendererSchedulerImpl::BroadcastConsoleWarning( 1335 void RendererSchedulerImpl::BroadcastConsoleWarning(
1305 const std::string& message) { 1336 const std::string& message) {
1306 helper_.CheckOnValidThread(); 1337 helper_.CheckOnValidThread();
1307 for (auto& web_view_scheduler : MainThreadOnly().web_view_schedulers_) 1338 for (auto& web_view_scheduler : MainThreadOnly().web_view_schedulers)
1308 web_view_scheduler->AddConsoleWarning(message); 1339 web_view_scheduler->AddConsoleWarning(message);
1309 } 1340 }
1310 1341
1311 void RendererSchedulerImpl::OnTriedToExecuteBlockedTask( 1342 void RendererSchedulerImpl::OnTriedToExecuteBlockedTask(
1312 const TaskQueue& queue, 1343 const TaskQueue& queue,
1313 const base::PendingTask& task) { 1344 const base::PendingTask& task) {
1314 if (!MainThreadOnly().expensive_task_blocking_allowed || 1345 if (!MainThreadOnly().expensive_task_blocking_allowed ||
1315 MainThreadOnly().current_use_case == UseCase::TOUCHSTART || 1346 MainThreadOnly().current_use_case == UseCase::TOUCHSTART ||
1316 MainThreadOnly().longest_jank_free_task_duration < 1347 MainThreadOnly().longest_jank_free_task_duration <
1317 base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis) || 1348 base::TimeDelta::FromMilliseconds(kRailsResponseTimeMillis) ||
(...skipping 23 matching lines...) Expand all
1341 true; 1372 true;
1342 BroadcastConsoleWarning( 1373 BroadcastConsoleWarning(
1343 "Blink deferred a task in order to make scrolling smoother. " 1374 "Blink deferred a task in order to make scrolling smoother. "
1344 "Your timer and network tasks should take less than 50ms to run " 1375 "Your timer and network tasks should take less than 50ms to run "
1345 "to avoid this. Please see " 1376 "to avoid this. Please see "
1346 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail" 1377 "https://developers.google.com/web/tools/chrome-devtools/profile/evaluat e-performance/rail"
1347 " and https://crbug.com/574343#c40 for more information."); 1378 " and https://crbug.com/574343#c40 for more information.");
1348 } 1379 }
1349 } 1380 }
1350 1381
1382 // static
1383 const char* RendererSchedulerImpl::UseCaseToString(UseCase use_case) {
1384 switch (use_case) {
1385 case UseCase::NONE:
1386 return "none";
1387 case UseCase::COMPOSITOR_GESTURE:
1388 return "compositor_gesture";
1389 case UseCase::MAIN_THREAD_CUSTOM_INPUT_HANDLING:
1390 return "main_thread_custom_input_handling";
1391 case UseCase::SYNCHRONIZED_GESTURE:
1392 return "synchronized_gesture";
1393 case UseCase::TOUCHSTART:
1394 return "touchstart";
1395 case UseCase::LOADING:
1396 return "loading";
1397 case UseCase::MAIN_THREAD_GESTURE:
1398 return "main_thread_gesture";
1399 default:
1400 NOTREACHED();
1401 return nullptr;
1402 }
1403 }
1404
1405 // static
1406 const char* RendererSchedulerImpl::RAILModeToString(v8::RAILMode rail_mode) {
1407 switch (rail_mode) {
1408 case v8::PERFORMANCE_DEFAULT:
1409 return "default";
1410 case v8::PERFORMANCE_RESPONSE:
1411 return "response";
1412 case v8::PERFORMANCE_ANIMATION:
1413 return "animation";
1414 case v8::PERFORMANCE_IDLE:
1415 return "idle";
1416 case v8::PERFORMANCE_LOAD:
1417 return "load";
1418 default:
1419 NOTREACHED();
1420 return nullptr;
1421 }
1422 }
1423
1351 } // namespace scheduler 1424 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698