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

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

Issue 1914373004: scheduler: Only prioritize rAF if it is fast (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Require 20% idle time, add tests. Created 4 years, 7 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
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 ForceUpdatePolicyAndGetCurrentUseCase()); 2801 ForceUpdatePolicyAndGetCurrentUseCase());
2802 2802
2803 // Make sure TouchStart causes a policy change. 2803 // Make sure TouchStart causes a policy change.
2804 scheduler_->DidHandleInputEventOnCompositorThread( 2804 scheduler_->DidHandleInputEventOnCompositorThread(
2805 FakeInputEvent(blink::WebInputEvent::TouchStart), 2805 FakeInputEvent(blink::WebInputEvent::TouchStart),
2806 RendererScheduler::InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD); 2806 RendererScheduler::InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD);
2807 EXPECT_EQ(RendererScheduler::UseCase::TOUCHSTART, 2807 EXPECT_EQ(RendererScheduler::UseCase::TOUCHSTART,
2808 ForceUpdatePolicyAndGetCurrentUseCase()); 2808 ForceUpdatePolicyAndGetCurrentUseCase());
2809 } 2809 }
2810 2810
2811 TEST_F(RendererSchedulerImplTest, SYNCHRONIZED_GESTURE_CompositingExpensive) {
2812 SimulateCompositorGestureStart(TouchEventPolicy::SEND_TOUCH_START);
2813
2814 // With the compositor task taking 20ms, there is not enough time to run
2815 // other tasks in the same 16ms frame. To avoid starvation, compositing tasks
2816 // should therefore not get prioritized.
2817 std::vector<std::string> run_order;
2818 for (int i = 0; i < 1000; i++)
2819 PostTestTasks(&run_order, "T1");
2820
2821 for (int i = 0; i < 100; i++) {
2822 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2823 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(),
2824 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL);
2825 begin_frame_args.on_critical_path = true;
2826 scheduler_->WillBeginFrame(begin_frame_args);
2827 scheduler_->DidHandleInputEventOnCompositorThread(
2828 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
2829 RendererScheduler::InputEventState::EVENT_CONSUMED_BY_COMPOSITOR);
2830
2831 simulate_compositor_task_ran_ = false;
2832 compositor_task_runner_->PostTask(
2833 FROM_HERE,
2834 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask,
2835 base::Unretained(this),
2836 base::TimeDelta::FromMilliseconds(20)));
2837
2838 mock_task_runner_->RunTasksWhile(
2839 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending,
2840 base::Unretained(this)));
2841 EXPECT_EQ(UseCase::SYNCHRONIZED_GESTURE, CurrentUseCase()) << "i = " << i;
2842 }
2843
2844 // Timer tasks should not have been starved by the expensive compositor
2845 // tasks.
2846 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY,
2847 scheduler_->CompositorTaskRunner()->GetQueuePriority());
2848 EXPECT_EQ(1000u, run_order.size());
2849 }
2850
2851 TEST_F(RendererSchedulerImplTest, MAIN_THREAD_GESTURE_CompositingExpensive) {
2852 SimulateMainThreadGestureStart(TouchEventPolicy::DONT_SEND_TOUCH_START,
2853 blink::WebInputEvent::GestureScrollBegin);
2854
2855 // With the compositor task taking 20ms, there is not enough time to run
2856 // other tasks in the same 16ms frame. To avoid starvation, compositing tasks
2857 // should therefore not get prioritized.
2858 std::vector<std::string> run_order;
2859 for (int i = 0; i < 1000; i++)
2860 PostTestTasks(&run_order, "T1");
2861
2862 for (int i = 0; i < 100; i++) {
2863 cc::BeginFrameArgs begin_frame_args = cc::BeginFrameArgs::Create(
2864 BEGINFRAME_FROM_HERE, clock_->NowTicks(), base::TimeTicks(),
2865 base::TimeDelta::FromMilliseconds(16), cc::BeginFrameArgs::NORMAL);
2866 begin_frame_args.on_critical_path = true;
2867 scheduler_->WillBeginFrame(begin_frame_args);
2868 scheduler_->DidHandleInputEventOnCompositorThread(
2869 FakeInputEvent(blink::WebInputEvent::GestureScrollUpdate),
2870 RendererScheduler::InputEventState::EVENT_FORWARDED_TO_MAIN_THREAD);
2871
2872 simulate_compositor_task_ran_ = false;
2873 compositor_task_runner_->PostTask(
2874 FROM_HERE,
2875 base::Bind(&RendererSchedulerImplTest::SimulateMainThreadCompositorTask,
2876 base::Unretained(this),
2877 base::TimeDelta::FromMilliseconds(20)));
2878
2879 mock_task_runner_->RunTasksWhile(
2880 base::Bind(&RendererSchedulerImplTest::SimulatedCompositorTaskPending,
2881 base::Unretained(this)));
2882 EXPECT_EQ(UseCase::MAIN_THREAD_GESTURE, CurrentUseCase()) << "i = " << i;
2883 }
2884
2885 // Timer tasks should not have been starved by the expensive compositor
2886 // tasks.
2887 EXPECT_EQ(TaskQueue::NORMAL_PRIORITY,
2888 scheduler_->CompositorTaskRunner()->GetQueuePriority());
2889 EXPECT_EQ(1000u, run_order.size());
2890 }
2891
2811 } // namespace scheduler 2892 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/renderer_scheduler_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698