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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 672 } | 672 } |
| 673 | 673 |
| 674 if (new_policy_duration > base::TimeDelta()) { | 674 if (new_policy_duration > base::TimeDelta()) { |
| 675 MainThreadOnly().current_policy_expiration_time = now + new_policy_duration; | 675 MainThreadOnly().current_policy_expiration_time = now + new_policy_duration; |
| 676 delayed_update_policy_runner_.SetDeadline(FROM_HERE, new_policy_duration, | 676 delayed_update_policy_runner_.SetDeadline(FROM_HERE, new_policy_duration, |
| 677 now); | 677 now); |
| 678 } else { | 678 } else { |
| 679 MainThreadOnly().current_policy_expiration_time = base::TimeTicks(); | 679 MainThreadOnly().current_policy_expiration_time = base::TimeTicks(); |
| 680 } | 680 } |
| 681 | 681 |
| 682 // Avoid prioritizing main thread compositing (e.g., rAF) if it is extremely | |
| 683 // slow, because that can cause starvation in other task sources. | |
| 684 bool main_thread_compositing_is_fast = | |
| 685 MainThreadOnly().idle_time_estimator.GetExpectedIdleDuration( | |
| 686 MainThreadOnly().compositor_frame_interval) > | |
| 687 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.
| |
| 688 | |
| 682 Policy new_policy; | 689 Policy new_policy; |
| 683 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; | 690 ExpensiveTaskPolicy expensive_task_policy = ExpensiveTaskPolicy::RUN; |
| 684 switch (use_case) { | 691 switch (use_case) { |
| 685 case UseCase::COMPOSITOR_GESTURE: | 692 case UseCase::COMPOSITOR_GESTURE: |
| 686 if (touchstart_expected_soon) { | 693 if (touchstart_expected_soon) { |
| 687 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 694 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 688 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 695 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 689 } else { | 696 } else { |
| 690 // What we really want to do is priorize loading tasks, but that doesn't | 697 // What we really want to do is priorize loading tasks, but that doesn't |
| 691 // seem to be safe. Instead we do that by proxy by deprioritizing | 698 // seem to be safe. Instead we do that by proxy by deprioritizing |
| 692 // compositor tasks. This should be safe since we've already gone to the | 699 // compositor tasks. This should be safe since we've already gone to the |
| 693 // pain of fixing ordering issues with them. | 700 // pain of fixing ordering issues with them. |
| 694 new_policy.compositor_queue_policy.priority = | 701 new_policy.compositor_queue_policy.priority = |
| 695 TaskQueue::BEST_EFFORT_PRIORITY; | 702 TaskQueue::BEST_EFFORT_PRIORITY; |
| 696 } | 703 } |
| 697 break; | 704 break; |
| 698 | 705 |
| 699 case UseCase::SYNCHRONIZED_GESTURE: | 706 case UseCase::SYNCHRONIZED_GESTURE: |
| 700 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 707 new_policy.compositor_queue_policy.priority = |
| 708 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY | |
| 709 : TaskQueue::NORMAL_PRIORITY; | |
| 701 if (touchstart_expected_soon) { | 710 if (touchstart_expected_soon) { |
| 702 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 711 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 703 } else { | 712 } else { |
| 704 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; | 713 expensive_task_policy = ExpensiveTaskPolicy::THROTTLE; |
| 705 } | 714 } |
| 706 break; | 715 break; |
| 707 | 716 |
| 708 case UseCase::MAIN_THREAD_GESTURE: | 717 case UseCase::MAIN_THREAD_GESTURE: |
| 709 // In main thread gestures we don't have perfect knowledge about which | 718 // In main thread gestures we don't have perfect knowledge about which |
| 710 // things we should be prioritizing, so we don't attempt to block | 719 // things we should be prioritizing, so we don't attempt to block |
| 711 // expensive tasks because we don't know whether they were integral to the | 720 // expensive tasks because we don't know whether they were integral to the |
| 712 // page's functionality or not. | 721 // page's functionality or not. |
| 713 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 722 new_policy.compositor_queue_policy.priority = |
| 723 main_thread_compositing_is_fast ? TaskQueue::HIGH_PRIORITY | |
| 724 : TaskQueue::NORMAL_PRIORITY; | |
| 714 break; | 725 break; |
| 715 | 726 |
| 716 case UseCase::TOUCHSTART: | 727 case UseCase::TOUCHSTART: |
| 717 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; | 728 new_policy.compositor_queue_policy.priority = TaskQueue::HIGH_PRIORITY; |
| 718 new_policy.loading_queue_policy.is_enabled = false; | 729 new_policy.loading_queue_policy.is_enabled = false; |
| 719 new_policy.timer_queue_policy.is_enabled = false; | 730 new_policy.timer_queue_policy.is_enabled = false; |
| 720 // NOTE this is a nop due to the above. | 731 // NOTE this is a nop due to the above. |
| 721 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; | 732 expensive_task_policy = ExpensiveTaskPolicy::BLOCK; |
| 722 break; | 733 break; |
| 723 | 734 |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1245 } | 1256 } |
| 1246 MainThreadOnly().have_reported_blocking_intervention_since_navigation = | 1257 MainThreadOnly().have_reported_blocking_intervention_since_navigation = |
| 1247 true; | 1258 true; |
| 1248 BroadcastConsoleWarning( | 1259 BroadcastConsoleWarning( |
| 1249 "Deferred long-running timer task(s) to improve scrolling smoothness. " | 1260 "Deferred long-running timer task(s) to improve scrolling smoothness. " |
| 1250 "See crbug.com/574343."); | 1261 "See crbug.com/574343."); |
| 1251 } | 1262 } |
| 1252 } | 1263 } |
| 1253 | 1264 |
| 1254 } // namespace scheduler | 1265 } // namespace scheduler |
| OLD | NEW |