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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 2418593002: Fix scheduler bug in skipping main frames (Closed)
Patch Set: Created 4 years, 2 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
« cc/scheduler/scheduler.cc ('K') | « cc/scheduler/scheduler.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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 BeginFrameArgs args = 408 BeginFrameArgs args =
409 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); 409 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
410 fake_external_begin_frame_source_->TestOnBeginFrame(args); 410 fake_external_begin_frame_source_->TestOnBeginFrame(args);
411 return args; 411 return args;
412 } 412 }
413 413
414 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { 414 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const {
415 return fake_external_begin_frame_source_.get(); 415 return fake_external_begin_frame_source_.get();
416 } 416 }
417 417
418 void AdvanceAndMissOneFrame();
418 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); 419 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame);
419 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline); 420 void ImplFrameSkippedAfterLateSwapAck(bool swap_ack_before_deadline);
420 void ImplFrameNotSkippedAfterLateSwapAck(); 421 void ImplFrameNotSkippedAfterLateSwapAck();
421 void BeginFramesNotFromClient(BeginFrameSourceType bfs_type); 422 void BeginFramesNotFromClient(BeginFrameSourceType bfs_type);
422 void BeginFramesNotFromClient_SwapThrottled(BeginFrameSourceType bfs_type); 423 void BeginFramesNotFromClient_SwapThrottled(BeginFrameSourceType bfs_type);
423 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority, 424 bool BeginMainFrameOnCriticalPath(TreePriority tree_priority,
424 ScrollHandlerState scroll_handler_state, 425 ScrollHandlerState scroll_handler_state,
425 base::TimeDelta durations); 426 base::TimeDelta durations);
426 427
427 std::unique_ptr<base::SimpleTestTickClock> now_src_; 428 std::unique_ptr<base::SimpleTestTickClock> now_src_;
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 client_->Reset(); 1276 client_->Reset();
1276 scheduler_->DidLoseCompositorFrameSink(); 1277 scheduler_->DidLoseCompositorFrameSink();
1277 EXPECT_TRUE(client_->IsInsideBeginImplFrame()); 1278 EXPECT_TRUE(client_->IsInsideBeginImplFrame());
1278 task_runner().RunPendingTasks(); // Run posted deadline. 1279 task_runner().RunPendingTasks(); // Run posted deadline.
1279 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0, 1280 EXPECT_ACTION("ScheduledActionBeginCompositorFrameSinkCreation", client_, 0,
1280 3); 1281 3);
1281 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3); 1282 EXPECT_ACTION("RemoveObserver(this)", client_, 1, 3);
1282 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); 1283 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
1283 } 1284 }
1284 1285
1285 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( 1286 void SchedulerTest::AdvanceAndMissOneFrame() {
1286 bool expect_send_begin_main_frame) {
1287 // Impl thread hits deadline before commit finishes. 1287 // Impl thread hits deadline before commit finishes.
1288 scheduler_->SetNeedsBeginMainFrame(); 1288 scheduler_->SetNeedsBeginMainFrame();
1289 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1289 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
1290 EXPECT_SCOPED(AdvanceFrame()); 1290 EXPECT_SCOPED(AdvanceFrame());
1291 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); 1291 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline());
1292 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 1292 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1293 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); 1293 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1294 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks()); 1294 scheduler_->NotifyBeginMainFrameStarted(base::TimeTicks());
1295 scheduler_->NotifyReadyToCommit(); 1295 scheduler_->NotifyReadyToCommit();
1296 scheduler_->NotifyReadyToActivate(); 1296 scheduler_->NotifyReadyToActivate();
1297 EXPECT_ACTION("AddObserver(this)", client_, 0, 5); 1297 EXPECT_ACTION("AddObserver(this)", client_, 0, 5);
1298 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); 1298 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5);
1299 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); 1299 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5);
1300 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); 1300 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5);
1301 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); 1301 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5);
1302 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); 1302 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1303 client_->Reset();
1304 }
1303 1305
1304 client_->Reset(); 1306 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit(
1307 bool expect_send_begin_main_frame) {
1308 AdvanceAndMissOneFrame();
1309
1305 scheduler_->SetNeedsBeginMainFrame(); 1310 scheduler_->SetNeedsBeginMainFrame();
1306 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); 1311 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1307 EXPECT_SCOPED(AdvanceFrame()); 1312 EXPECT_SCOPED(AdvanceFrame());
1308 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); 1313 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1309 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true)); 1314 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1310 EXPECT_EQ(expect_send_begin_main_frame, 1315 EXPECT_EQ(expect_send_begin_main_frame,
1311 scheduler_->MainThreadMissedLastDeadline()); 1316 scheduler_->MainThreadMissedLastDeadline());
1312 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame")); 1317 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame"));
1313 EXPECT_EQ(expect_send_begin_main_frame, 1318 EXPECT_EQ(expect_send_begin_main_frame,
1314 client_->HasAction("ScheduledActionSendBeginMainFrame")); 1319 client_->HasAction("ScheduledActionSendBeginMainFrame"));
1315 } 1320 }
1316 1321
1322 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateBeginFrame) {
1323 // If a begin frame is delivered extremely late (because the browser has
1324 // some contention), make sure that the main frame is not skipped even
1325 // if it can activate before the deadline.
1326 SetUpScheduler(EXTERNAL_BFS);
1327 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1328
1329 AdvanceAndMissOneFrame();
1330
1331 // Advance frame and create a begin frame.
sunnyps 2016/10/12 20:51:46 Why do we need this extra frame in between?
enne (OOO) 2016/10/13 17:09:44 Which extra frame? There's one frame where the mai
sunnyps 2016/10/13 20:25:57 Ooh, sorry. Misread that.
1332 now_src_->Advance(BeginFrameArgs::DefaultInterval());
1333 BeginFrameArgs args =
1334 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src());
1335
1336 // Deliver this begin frame super late.
1337 now_src_->Advance(BeginFrameArgs::DefaultInterval() * 100);
1338 fake_external_begin_frame_source_->TestOnBeginFrame(args);
1339
1340 scheduler_->SetNeedsBeginMainFrame();
sunnyps 2016/10/12 20:51:46 nit: Can you call SetNeedsBeginMainFrame before se
enne (OOO) 2016/10/13 17:09:44 Done.
1341 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline());
1342 task_runner().RunTasksWhile(client_->InsideBeginImplFrame(true));
1343 EXPECT_EQ(true, scheduler_->MainThreadMissedLastDeadline());
1344 EXPECT_TRUE(client_->HasAction("WillBeginImplFrame"));
sunnyps 2016/10/12 20:51:46 nit: Can you use EXPECT_ACTION here?
enne (OOO) 2016/10/13 17:09:44 Done.
1345 EXPECT_EQ(true, client_->HasAction("ScheduledActionSendBeginMainFrame"));
1346 }
1347
1317 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { 1348 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) {
1318 SetUpScheduler(EXTERNAL_BFS); 1349 SetUpScheduler(EXTERNAL_BFS);
1319 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration); 1350 fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
1320 1351
1321 bool expect_send_begin_main_frame = false; 1352 bool expect_send_begin_main_frame = false;
1322 EXPECT_SCOPED( 1353 EXPECT_SCOPED(
1323 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1354 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1324 } 1355 }
1325 1356
1326 // Response times of BeginMainFrame's without the critical path flag set 1357 // Response times of BeginMainFrame's without the critical path flag set
(...skipping 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 } 3273 }
3243 3274
3244 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) { 3275 TEST_F(SchedulerTest, BeginMainFrameOnCriticalPath_AHS) {
3245 EXPECT_FALSE(BeginMainFrameOnCriticalPath( 3276 EXPECT_FALSE(BeginMainFrameOnCriticalPath(
3246 SMOOTHNESS_TAKES_PRIORITY, 3277 SMOOTHNESS_TAKES_PRIORITY,
3247 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration)); 3278 ScrollHandlerState::SCROLL_AFFECTS_SCROLL_HANDLER, kSlowDuration));
3248 } 3279 }
3249 3280
3250 } // namespace 3281 } // namespace
3251 } // namespace cc 3282 } // namespace cc
OLDNEW
« cc/scheduler/scheduler.cc ('K') | « cc/scheduler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698