Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history = | 239 scoped_ptr<FakeCompositorTimingHistory> fake_compositor_timing_history = |
| 240 FakeCompositorTimingHistory::Create(); | 240 FakeCompositorTimingHistory::Create(); |
| 241 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); | 241 fake_compositor_timing_history_ = fake_compositor_timing_history.get(); |
| 242 | 242 |
| 243 scheduler_ = TestScheduler::Create( | 243 scheduler_ = TestScheduler::Create( |
| 244 now_src_.get(), client_.get(), scheduler_settings_, 0, | 244 now_src_.get(), client_.get(), scheduler_settings_, 0, |
| 245 task_runner_.get(), fake_external_begin_frame_source_.get(), | 245 task_runner_.get(), fake_external_begin_frame_source_.get(), |
| 246 fake_compositor_timing_history.Pass()); | 246 fake_compositor_timing_history.Pass()); |
| 247 DCHECK(scheduler_); | 247 DCHECK(scheduler_); |
| 248 client_->set_scheduler(scheduler_.get()); | 248 client_->set_scheduler(scheduler_.get()); |
| 249 | |
| 250 // Use large estimates by default to avoid latency recovery | |
| 251 // in most tests. | |
| 252 base::TimeDelta slow_duration = base::TimeDelta::FromSeconds(1); | |
| 253 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | |
| 254 | |
| 249 return scheduler_.get(); | 255 return scheduler_.get(); |
| 250 } | 256 } |
| 251 | 257 |
| 252 void CreateSchedulerAndInitSurface() { | 258 void CreateSchedulerAndInitSurface() { |
| 253 CreateScheduler(); | 259 CreateScheduler(); |
| 254 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); | 260 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); |
| 255 } | 261 } |
| 256 | 262 |
| 257 void SetUpScheduler(bool initSurface) { | 263 void SetUpScheduler(bool initSurface) { |
| 258 SetUpScheduler(make_scoped_ptr(new FakeSchedulerClient), initSurface); | 264 SetUpScheduler(make_scoped_ptr(new FakeSchedulerClient), initSurface); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 BeginFrameArgs args = | 383 BeginFrameArgs args = |
| 378 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 384 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| 379 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 385 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
| 380 return args; | 386 return args; |
| 381 } | 387 } |
| 382 | 388 |
| 383 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { | 389 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { |
| 384 return fake_external_begin_frame_source_.get(); | 390 return fake_external_begin_frame_source_.get(); |
| 385 } | 391 } |
| 386 | 392 |
| 387 void MainFrameInHighLatencyMode( | 393 void CheckMainFrameSkippedAfterLateCommit(bool expect_send_begin_main_frame); |
| 388 int64 begin_main_frame_to_commit_estimate_in_ms, | 394 void ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( |
|
sunnyps
2015/07/09 23:44:30
I think the "MainThreadMakesDeadline" suffix is in
brianderson
2015/07/10 00:34:08
Done.
| |
| 389 int64 commit_to_activate_estimate_in_ms, | 395 bool swap_ack_before_deadline); |
| 390 bool impl_latency_takes_priority, | 396 void ImplFrameSkippedAfterLateSwapAck_MainThreadMissesDeadline(); |
|
sunnyps
2015/07/09 23:44:30
This isn't implemented anywhere.
brianderson
2015/07/10 00:34:08
Removed.
| |
| 391 bool should_send_begin_main_frame); | 397 void ImplFrameIsNotSkippedAfterLateSwapAck(); |
| 392 void BeginFramesNotFromClient(bool use_external_begin_frame_source, | 398 void BeginFramesNotFromClient(bool use_external_begin_frame_source, |
| 393 bool throttle_frame_production); | 399 bool throttle_frame_production); |
| 394 void BeginFramesNotFromClient_SwapThrottled( | 400 void BeginFramesNotFromClient_SwapThrottled( |
| 395 bool use_external_begin_frame_source, | 401 bool use_external_begin_frame_source, |
| 396 bool throttle_frame_production); | 402 bool throttle_frame_production); |
| 397 | 403 |
| 398 scoped_ptr<base::SimpleTestTickClock> now_src_; | 404 scoped_ptr<base::SimpleTestTickClock> now_src_; |
| 399 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 405 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 400 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; | 406 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source_; |
| 401 SchedulerSettings scheduler_settings_; | 407 SchedulerSettings scheduler_settings_; |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1282 // Scheduler loses output surface, and stops waiting for ready to draw signal. | 1288 // Scheduler loses output surface, and stops waiting for ready to draw signal. |
| 1283 client_->Reset(); | 1289 client_->Reset(); |
| 1284 scheduler_->DidLoseOutputSurface(); | 1290 scheduler_->DidLoseOutputSurface(); |
| 1285 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1291 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1286 task_runner().RunPendingTasks(); // Run posted deadline. | 1292 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1287 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); | 1293 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); |
| 1288 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); | 1294 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 1289 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 1295 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 1290 } | 1296 } |
| 1291 | 1297 |
| 1292 void SchedulerTest::MainFrameInHighLatencyMode( | 1298 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( |
| 1293 int64 begin_main_frame_to_commit_estimate_in_ms, | 1299 bool expect_send_begin_main_frame) { |
| 1294 int64 commit_to_activate_estimate_in_ms, | |
| 1295 bool impl_latency_takes_priority, | |
| 1296 bool should_send_begin_main_frame) { | |
| 1297 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1298 SetUpScheduler(true); | |
| 1299 | |
| 1300 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1301 base::TimeDelta::FromMilliseconds( | |
| 1302 begin_main_frame_to_commit_estimate_in_ms)); | |
| 1303 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | |
| 1304 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); | |
| 1305 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1306 base::TimeDelta::FromMilliseconds(1)); | |
| 1307 | |
| 1308 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); | |
| 1309 | |
| 1310 // Impl thread hits deadline before commit finishes. | 1300 // Impl thread hits deadline before commit finishes. |
| 1311 scheduler_->SetNeedsCommit(); | 1301 scheduler_->SetNeedsCommit(); |
| 1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1302 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1313 EXPECT_SCOPED(AdvanceFrame()); | 1303 EXPECT_SCOPED(AdvanceFrame()); |
| 1314 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1304 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1315 task_runner().RunPendingTasks(); // Run posted deadline. | 1305 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1316 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1306 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1317 scheduler_->NotifyBeginMainFrameStarted(); | 1307 scheduler_->NotifyBeginMainFrameStarted(); |
| 1318 scheduler_->NotifyReadyToCommit(); | 1308 scheduler_->NotifyReadyToCommit(); |
| 1319 scheduler_->NotifyReadyToActivate(); | 1309 scheduler_->NotifyReadyToActivate(); |
| 1320 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1310 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); |
| 1321 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1311 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); |
| 1312 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | |
| 1313 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); | |
| 1314 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); | |
| 1315 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1322 | 1316 |
| 1323 client_->Reset(); | 1317 client_->Reset(); |
| 1324 scheduler_->SetNeedsCommit(); | 1318 scheduler_->SetNeedsCommit(); |
| 1325 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1319 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1326 EXPECT_SCOPED(AdvanceFrame()); | 1320 EXPECT_SCOPED(AdvanceFrame()); |
| 1327 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1321 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1328 task_runner().RunPendingTasks(); // Run posted deadline. | 1322 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1329 EXPECT_EQ(scheduler_->MainThreadIsInHighLatencyMode(), | 1323 EXPECT_EQ(expect_send_begin_main_frame, |
| 1330 should_send_begin_main_frame); | 1324 scheduler_->MainThreadIsInHighLatencyMode()); |
| 1331 EXPECT_EQ(client_->HasAction("ScheduledActionSendBeginMainFrame"), | 1325 EXPECT_EQ(expect_send_begin_main_frame, |
| 1332 should_send_begin_main_frame); | 1326 client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1333 } | 1327 } |
| 1334 | 1328 |
| 1335 TEST_F(SchedulerTest, | 1329 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { |
| 1336 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) { | 1330 scheduler_settings_.use_external_begin_frame_source = true; |
| 1337 // Set up client so that estimates indicate that we can commit and activate | 1331 SetUpScheduler(true); |
| 1338 // before the deadline (~8ms by default). | 1332 |
| 1339 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 1, false, false)); | 1333 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1340 } | 1334 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); |
| 1341 | 1335 |
| 1342 TEST_F(SchedulerTest, NotSkipMainFrameIfHighLatencyAndCanCommitTooLong) { | 1336 bool expect_send_begin_main_frame = false; |
| 1343 // Set up client so that estimates indicate that the commit cannot finish | 1337 EXPECT_SCOPED( |
| 1344 // before the deadline (~8ms by default). | 1338 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1345 EXPECT_SCOPED(MainFrameInHighLatencyMode(10, 1, false, true)); | 1339 } |
| 1346 } | 1340 |
| 1347 | 1341 TEST_F(SchedulerTest, |
| 1348 TEST_F(SchedulerTest, NotSkipMainFrameIfHighLatencyAndCanActivateTooLong) { | 1342 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { |
| 1349 // Set up client so that estimates indicate that the activate cannot finish | 1343 scheduler_settings_.use_external_begin_frame_source = true; |
| 1350 // before the deadline (~8ms by default). | 1344 SetUpScheduler(true); |
| 1351 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 10, false, true)); | 1345 scheduler_->SetImplLatencyTakesPriority(true); |
| 1352 } | 1346 |
| 1353 | 1347 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1354 TEST_F(SchedulerTest, NotSkipMainFrameInPreferImplLatencyMode) { | 1348 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); |
| 1355 // Set up client so that estimates indicate that we can commit and activate | 1349 |
| 1356 // before the deadline (~8ms by default), but also enable impl latency takes | 1350 bool expect_send_begin_main_frame = true; |
| 1357 // priority mode. | 1351 EXPECT_SCOPED( |
| 1358 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 1, true, true)); | 1352 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); |
| 1353 } | |
| 1354 | |
| 1355 TEST_F(SchedulerTest, | |
| 1356 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { | |
| 1357 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1358 SetUpScheduler(true); | |
| 1359 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1360 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1361 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1362 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1363 slow_duration); | |
| 1364 | |
| 1365 bool expect_send_begin_main_frame = true; | |
| 1366 EXPECT_SCOPED( | |
| 1367 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | |
| 1368 } | |
| 1369 | |
| 1370 TEST_F(SchedulerTest, | |
| 1371 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { | |
| 1372 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1373 SetUpScheduler(true); | |
| 1374 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1375 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1376 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1377 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | |
| 1378 slow_duration); | |
| 1379 | |
| 1380 bool expect_send_begin_main_frame = true; | |
| 1381 EXPECT_SCOPED( | |
| 1382 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | |
| 1383 } | |
| 1384 | |
| 1385 TEST_F(SchedulerTest, | |
| 1386 MainFrameNotSkippedAfterLateCommit_ActivateEstimateTooLong) { | |
| 1387 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1388 SetUpScheduler(true); | |
| 1389 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1390 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1391 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1392 fake_compositor_timing_history_->SetActivateDurationEstimate(slow_duration); | |
| 1393 | |
| 1394 bool expect_send_begin_main_frame = true; | |
| 1395 EXPECT_SCOPED( | |
| 1396 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | |
| 1397 } | |
| 1398 | |
| 1399 TEST_F(SchedulerTest, MainFrameNotSkippedAfterLateCommit_DrawEstimateTooLong) { | |
| 1400 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1401 SetUpScheduler(true); | |
| 1402 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1403 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1404 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1405 fake_compositor_timing_history_->SetDrawDurationEstimate(slow_duration); | |
| 1406 | |
| 1407 bool expect_send_begin_main_frame = true; | |
| 1408 EXPECT_SCOPED( | |
| 1409 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); | |
| 1410 } | |
| 1411 | |
| 1412 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( | |
| 1413 bool swap_ack_before_deadline) { | |
| 1414 // To get into a high latency state, this test disables automatic swap acks. | |
| 1415 scheduler_->SetMaxSwapsPending(1); | |
| 1416 client_->SetAutomaticSwapAck(false); | |
| 1417 | |
| 1418 // Draw and swap for first BeginFrame | |
| 1419 client_->Reset(); | |
| 1420 scheduler_->SetNeedsCommit(); | |
| 1421 scheduler_->SetNeedsRedraw(); | |
| 1422 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1423 SendNextBeginFrame(); | |
| 1424 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 4); | |
| 1425 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 4); | |
| 1426 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | |
| 1427 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 3, 4); | |
| 1428 | |
| 1429 client_->Reset(); | |
| 1430 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1431 scheduler_->NotifyReadyToCommit(); | |
| 1432 scheduler_->NotifyReadyToActivate(); | |
| 1433 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1434 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1435 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | |
| 1436 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | |
| 1437 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | |
| 1438 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | |
| 1439 | |
| 1440 // Verify we skip every other frame if the swap ack consistently | |
| 1441 // comes back late. | |
| 1442 for (int i = 0; i < 10; i++) { | |
| 1443 // Not calling scheduler_->DidSwapBuffersComplete() until after next | |
| 1444 // BeginImplFrame puts the impl thread in high latency mode. | |
| 1445 client_->Reset(); | |
| 1446 scheduler_->SetNeedsCommit(); | |
| 1447 scheduler_->SetNeedsRedraw(); | |
| 1448 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1449 SendNextBeginFrame(); | |
| 1450 // Verify that we skip the BeginImplFrame | |
| 1451 EXPECT_NO_ACTION(client_); | |
| 1452 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 1453 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1454 | |
| 1455 // Verify that we do not perform any actions after we are no longer | |
| 1456 // swap throttled. | |
| 1457 client_->Reset(); | |
| 1458 if (swap_ack_before_deadline) { | |
| 1459 // It shouldn't matter if the swap ack comes back before the deadline... | |
| 1460 scheduler_->DidSwapBuffersComplete(); | |
| 1461 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1462 } else { | |
| 1463 // ... or after the deadline. | |
| 1464 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1465 scheduler_->DidSwapBuffersComplete(); | |
| 1466 } | |
| 1467 EXPECT_NO_ACTION(client_); | |
| 1468 | |
| 1469 // Verify that we start the next BeginImplFrame and continue normally | |
| 1470 // after having just skipped a BeginImplFrame. | |
| 1471 client_->Reset(); | |
| 1472 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1473 SendNextBeginFrame(); | |
| 1474 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | |
| 1475 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | |
| 1476 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | |
| 1477 | |
| 1478 client_->Reset(); | |
| 1479 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1480 scheduler_->NotifyReadyToCommit(); | |
| 1481 scheduler_->NotifyReadyToActivate(); | |
| 1482 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1483 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | |
| 1484 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | |
| 1485 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | |
| 1486 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | |
| 1487 } | |
| 1488 } | |
| 1489 | |
| 1490 TEST_F(SchedulerTest, | |
| 1491 ImplFrameSkippedAfterLateSwapAck_FastEstimates_SwapAckThenDeadline) { | |
| 1492 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1493 SetUpScheduler(true); | |
| 1494 | |
| 1495 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1496 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1497 | |
| 1498 bool swap_ack_before_deadline = true; | |
| 1499 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( | |
| 1500 swap_ack_before_deadline)); | |
| 1501 } | |
| 1502 | |
| 1503 TEST_F(SchedulerTest, | |
| 1504 ImplFrameSkippedAfterLateSwapAck_FastEstimates_DeadlineThenSwapAck) { | |
| 1505 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1506 SetUpScheduler(true); | |
| 1507 | |
| 1508 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1509 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1510 | |
| 1511 bool swap_ack_before_deadline = false; | |
| 1512 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( | |
| 1513 swap_ack_before_deadline)); | |
| 1514 } | |
| 1515 | |
| 1516 TEST_F(SchedulerTest, | |
| 1517 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { | |
| 1518 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1519 SetUpScheduler(true); | |
| 1520 | |
| 1521 // Even if every estimate related to the main thread is slow, we should | |
| 1522 // still expect to recover impl thread latency if the draw is fast and we | |
| 1523 // are in impl latency takes priority. | |
| 1524 scheduler_->SetImplLatencyTakesPriority(true); | |
| 1525 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1526 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | |
| 1527 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1528 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); | |
| 1529 | |
| 1530 bool swap_ack_before_deadline = false; | |
| 1531 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( | |
| 1532 swap_ack_before_deadline)); | |
| 1533 } | |
| 1534 | |
| 1535 TEST_F(SchedulerTest, | |
| 1536 ImplFrameSkippedAfterLateSwapAck_OnlyImplSideUpdatesExpected) { | |
| 1537 // This tests that we recover impl thread latency when there are no commits. | |
| 1538 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1539 SetUpScheduler(true); | |
| 1540 | |
| 1541 // To get into a high latency state, this test disables automatic swap acks. | |
| 1542 scheduler_->SetMaxSwapsPending(1); | |
| 1543 client_->SetAutomaticSwapAck(false); | |
| 1544 | |
| 1545 // Even if every estimate related to the main thread is slow, we should | |
| 1546 // still expect to recover impl thread latency if there are no commits from | |
| 1547 // the main thread. | |
| 1548 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1549 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | |
| 1550 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1551 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); | |
| 1552 | |
| 1553 // Draw and swap for first BeginFrame | |
| 1554 client_->Reset(); | |
| 1555 scheduler_->SetNeedsRedraw(); | |
| 1556 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1557 SendNextBeginFrame(); | |
| 1558 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | |
| 1559 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | |
| 1560 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); | |
| 1561 | |
| 1562 client_->Reset(); | |
| 1563 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1564 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1565 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | |
| 1566 | |
| 1567 // Verify we skip every other frame if the swap ack consistently | |
| 1568 // comes back late. | |
| 1569 for (int i = 0; i < 10; i++) { | |
| 1570 // Not calling scheduler_->DidSwapBuffersComplete() until after next | |
| 1571 // BeginImplFrame puts the impl thread in high latency mode. | |
| 1572 client_->Reset(); | |
| 1573 scheduler_->SetNeedsRedraw(); | |
| 1574 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1575 SendNextBeginFrame(); | |
| 1576 // Verify that we skip the BeginImplFrame | |
| 1577 EXPECT_NO_ACTION(client_); | |
| 1578 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 1579 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1580 | |
| 1581 // Verify that we do not perform any actions after we are no longer | |
| 1582 // swap throttled. | |
| 1583 client_->Reset(); | |
| 1584 scheduler_->DidSwapBuffersComplete(); | |
| 1585 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
|
sunnyps
2015/07/09 23:44:30
In this mode the deadline will be an immediate one
brianderson
2015/07/10 00:34:08
Actually, there is no deadline to run at all since
sunnyps
2015/07/10 00:40:15
Oops, I meant the next deadline below for the fram
| |
| 1586 EXPECT_NO_ACTION(client_); | |
| 1587 | |
| 1588 // Verify that we start the next BeginImplFrame and continue normally | |
| 1589 // after having just skipped a BeginImplFrame. | |
| 1590 client_->Reset(); | |
| 1591 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1592 SendNextBeginFrame(); | |
| 1593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 1594 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | |
| 1595 | |
| 1596 client_->Reset(); | |
| 1597 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1598 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | |
| 1599 } | |
| 1600 } | |
| 1601 | |
| 1602 void SchedulerTest::ImplFrameIsNotSkippedAfterLateSwapAck() { | |
| 1603 // To get into a high latency state, this test disables automatic swap acks. | |
| 1604 scheduler_->SetMaxSwapsPending(1); | |
| 1605 client_->SetAutomaticSwapAck(false); | |
| 1606 | |
| 1607 // Draw and swap for first BeginFrame | |
| 1608 client_->Reset(); | |
| 1609 scheduler_->SetNeedsCommit(); | |
| 1610 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1611 SendNextBeginFrame(); | |
| 1612 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | |
| 1613 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | |
| 1614 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | |
| 1615 | |
| 1616 client_->Reset(); | |
| 1617 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1618 scheduler_->NotifyReadyToCommit(); | |
| 1619 scheduler_->NotifyReadyToActivate(); | |
| 1620 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1621 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1622 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | |
| 1623 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | |
| 1624 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | |
| 1625 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | |
| 1626 | |
| 1627 // Verify impl thread consistently operates in high latency mode | |
| 1628 // without skipping any frames. | |
| 1629 for (int i = 0; i < 10; i++) { | |
| 1630 // Not calling scheduler_->DidSwapBuffersComplete() until after next frame | |
| 1631 // puts the impl thread in high latency mode. | |
| 1632 client_->Reset(); | |
| 1633 scheduler_->SetNeedsCommit(); | |
| 1634 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1635 SendNextBeginFrame(); | |
| 1636 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | |
| 1637 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | |
| 1638 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1639 | |
| 1640 client_->Reset(); | |
| 1641 scheduler_->DidSwapBuffersComplete(); | |
| 1642 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1643 scheduler_->NotifyReadyToCommit(); | |
| 1644 scheduler_->NotifyReadyToActivate(); | |
| 1645 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1646 | |
| 1647 // Verify that we don't skip the actions of the BeginImplFrame | |
| 1648 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); | |
| 1649 EXPECT_ACTION("ScheduledActionCommit", client_, 1, 5); | |
| 1650 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 2, 5); | |
| 1651 EXPECT_ACTION("ScheduledActionAnimate", client_, 3, 5); | |
| 1652 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5); | |
| 1653 } | |
| 1654 } | |
| 1655 | |
| 1656 TEST_F(SchedulerTest, | |
| 1657 ImplFrameIsNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { | |
| 1658 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1659 SetUpScheduler(true); | |
| 1660 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1661 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1662 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1663 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1664 slow_duration); | |
| 1665 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | |
| 1666 } | |
| 1667 | |
| 1668 TEST_F(SchedulerTest, | |
| 1669 ImplFrameIsNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { | |
| 1670 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1671 SetUpScheduler(true); | |
| 1672 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1673 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1674 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1675 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | |
| 1676 slow_duration); | |
| 1677 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | |
| 1678 } | |
| 1679 | |
| 1680 TEST_F(SchedulerTest, | |
| 1681 ImplFrameIsNotSkippedAfterLateSwapAck_ActivateEstimateTooLong) { | |
| 1682 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1683 SetUpScheduler(true); | |
| 1684 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1685 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1686 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1687 fake_compositor_timing_history_->SetActivateDurationEstimate(slow_duration); | |
| 1688 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | |
| 1689 } | |
| 1690 | |
| 1691 TEST_F(SchedulerTest, | |
| 1692 ImplFrameIsNotSkippedAfterLateSwapAck_DrawEstimateTooLong) { | |
| 1693 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1694 SetUpScheduler(true); | |
| 1695 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1696 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1697 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1698 fake_compositor_timing_history_->SetDrawDurationEstimate(slow_duration); | |
| 1699 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); | |
| 1700 } | |
| 1701 | |
| 1702 TEST_F(SchedulerTest, | |
| 1703 MainFrameThenImplFrameSkippedAfterLateCommitAndLateSwapAck) { | |
| 1704 // Set up client with custom estimates. | |
| 1705 // This test starts off with expensive estimates to prevent latency recovery | |
| 1706 // initially, then lowers the estimates to enable it once both the main | |
| 1707 // and impl threads are in a high latency mode. | |
| 1708 scheduler_settings_.use_external_begin_frame_source = true; | |
| 1709 SetUpScheduler(true); | |
| 1710 | |
| 1711 auto slow_duration = base::TimeDelta::FromSeconds(1); | |
| 1712 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | |
| 1713 | |
| 1714 // To get into a high latency state, this test disables automatic swap acks. | |
| 1715 scheduler_->SetMaxSwapsPending(1); | |
| 1716 client_->SetAutomaticSwapAck(false); | |
| 1717 | |
| 1718 // Impl thread hits deadline before commit finishes to make | |
| 1719 // MainThreadIsInHighLatencyMode true | |
| 1720 client_->Reset(); | |
| 1721 scheduler_->SetNeedsCommit(); | |
| 1722 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1723 EXPECT_SCOPED(AdvanceFrame()); | |
| 1724 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1725 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1726 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1727 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1728 scheduler_->NotifyReadyToCommit(); | |
| 1729 scheduler_->NotifyReadyToActivate(); | |
| 1730 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1731 | |
| 1732 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); | |
| 1733 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); | |
| 1734 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | |
| 1735 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); | |
| 1736 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); | |
| 1737 | |
| 1738 // Draw and swap for first commit, start second commit. | |
| 1739 client_->Reset(); | |
| 1740 scheduler_->SetNeedsCommit(); | |
| 1741 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1742 EXPECT_SCOPED(AdvanceFrame()); | |
| 1743 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1744 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1745 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1746 scheduler_->NotifyReadyToCommit(); | |
| 1747 scheduler_->NotifyReadyToActivate(); | |
| 1748 | |
| 1749 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); | |
| 1750 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 6); | |
| 1751 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 6); | |
| 1752 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 6); | |
| 1753 EXPECT_ACTION("ScheduledActionCommit", client_, 4, 6); | |
| 1754 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 5, 6); | |
| 1755 | |
| 1756 // Don't call scheduler_->DidSwapBuffersComplete() until after next frame | |
| 1757 // to put the impl thread in a high latency mode. | |
| 1758 client_->Reset(); | |
| 1759 scheduler_->SetNeedsCommit(); | |
| 1760 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1761 EXPECT_SCOPED(AdvanceFrame()); | |
| 1762 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1763 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1764 | |
| 1765 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | |
| 1766 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | |
| 1767 // Note: BeginMainFrame and swap are skipped here because of | |
| 1768 // swap ack backpressure, not because of latency recovery. | |
| 1769 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | |
| 1770 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | |
| 1771 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1772 EXPECT_TRUE(scheduler_->WasSwapThrottledAtLastBeginFrame()); | |
| 1773 | |
| 1774 // Lower estimates so that the scheduler will attempt latency recovery. | |
| 1775 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | |
| 1776 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | |
| 1777 | |
| 1778 // Now that both threads are in a high latency mode, make sure we | |
| 1779 // skip the BeginMainFrame, then the BeginImplFrame, but not both | |
| 1780 // at the same time. | |
| 1781 | |
| 1782 // Verify we skip BeginMainFrame first. | |
| 1783 client_->Reset(); | |
| 1784 // Previous commit request is still outstanding. | |
| 1785 EXPECT_TRUE(scheduler_->NeedsCommit()); | |
| 1786 SendNextBeginFrame(); | |
| 1787 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1788 EXPECT_TRUE(scheduler_->WasSwapThrottledAtLastBeginFrame()); | |
| 1789 scheduler_->DidSwapBuffersComplete(); | |
| 1790 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1791 | |
| 1792 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1793 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | |
| 1794 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | |
| 1795 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); | |
| 1796 | |
| 1797 // Verify we skip the BeginImplFrame second. | |
| 1798 client_->Reset(); | |
| 1799 // Previous commit request is still outstanding. | |
| 1800 EXPECT_TRUE(scheduler_->NeedsCommit()); | |
| 1801 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1802 SendNextBeginFrame(); | |
| 1803 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1804 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1805 scheduler_->DidSwapBuffersComplete(); | |
| 1806 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1807 | |
| 1808 EXPECT_NO_ACTION(client_); | |
| 1809 | |
| 1810 // Then verify we operate in a low latency mode. | |
| 1811 client_->Reset(); | |
| 1812 // Previous commit request is still outstanding. | |
| 1813 EXPECT_TRUE(scheduler_->NeedsCommit()); | |
| 1814 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1815 SendNextBeginFrame(); | |
| 1816 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1817 scheduler_->NotifyBeginMainFrameStarted(); | |
| 1818 scheduler_->NotifyReadyToCommit(); | |
| 1819 scheduler_->NotifyReadyToActivate(); | |
| 1820 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | |
| 1821 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1822 scheduler_->DidSwapBuffersComplete(); | |
| 1823 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | |
| 1824 | |
| 1825 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); | |
| 1826 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 6); | |
| 1827 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 6); | |
| 1828 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 6); | |
| 1829 EXPECT_ACTION("ScheduledActionAnimate", client_, 4, 6); | |
| 1830 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 5, 6); | |
| 1359 } | 1831 } |
| 1360 | 1832 |
| 1361 TEST_F( | 1833 TEST_F( |
| 1362 SchedulerTest, | 1834 SchedulerTest, |
| 1363 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { | 1835 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { |
| 1364 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main | 1836 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main |
| 1365 // thread. This prevents the scheduler from receiving any pending swap acks. | 1837 // thread. This prevents the scheduler from receiving any pending swap acks. |
| 1366 | 1838 |
| 1367 // Since we are simulating a long commit, set up a client with draw duration | |
| 1368 // estimates that prevent skipping main frames to get to low latency mode. | |
| 1369 scheduler_settings_.use_external_begin_frame_source = true; | 1839 scheduler_settings_.use_external_begin_frame_source = true; |
| 1370 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1840 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1371 SetUpScheduler(true); | 1841 SetUpScheduler(true); |
| 1372 | 1842 |
| 1373 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1374 base::TimeDelta::FromMilliseconds(32)); | |
| 1375 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | |
| 1376 base::TimeDelta::FromMilliseconds(32)); | |
| 1377 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1378 base::TimeDelta::FromMilliseconds(1)); | |
| 1379 | |
| 1380 // Disables automatic swap acks so this test can force swap ack throttling | 1843 // Disables automatic swap acks so this test can force swap ack throttling |
| 1381 // to simulate a blocked Browser ui thread. | 1844 // to simulate a blocked Browser ui thread. |
| 1382 scheduler_->SetMaxSwapsPending(1); | 1845 scheduler_->SetMaxSwapsPending(1); |
| 1383 client_->SetAutomaticSwapAck(false); | 1846 client_->SetAutomaticSwapAck(false); |
| 1384 | 1847 |
| 1385 // Get a new active tree in main-thread high latency mode and put us | 1848 // Get a new active tree in main-thread high latency mode and put us |
| 1386 // in a swap throttled state. | 1849 // in a swap throttled state. |
| 1387 client_->Reset(); | 1850 client_->Reset(); |
| 1388 EXPECT_FALSE(scheduler_->CommitPending()); | 1851 EXPECT_FALSE(scheduler_->CommitPending()); |
| 1389 scheduler_->SetNeedsCommit(); | 1852 scheduler_->SetNeedsCommit(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 | 1899 |
| 1437 TEST_F(SchedulerTest, | 1900 TEST_F(SchedulerTest, |
| 1438 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) { | 1901 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) { |
| 1439 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main | 1902 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main |
| 1440 // thread. This prevents the scheduler from receiving any pending swap acks. | 1903 // thread. This prevents the scheduler from receiving any pending swap acks. |
| 1441 | 1904 |
| 1442 // This particular test makes sure we do not send a BeginMainFrame while | 1905 // This particular test makes sure we do not send a BeginMainFrame while |
| 1443 // swap trottled and we have a pending tree and active tree that | 1906 // swap trottled and we have a pending tree and active tree that |
| 1444 // still needs to be drawn for the first time. | 1907 // still needs to be drawn for the first time. |
| 1445 | 1908 |
| 1446 // Since we are simulating a long commit, set up a client with draw duration | |
| 1447 // estimates that prevent skipping main frames to get to low latency mode. | |
| 1448 scheduler_settings_.use_external_begin_frame_source = true; | 1909 scheduler_settings_.use_external_begin_frame_source = true; |
| 1449 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1910 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1450 scheduler_settings_.main_frame_before_activation_enabled = true; | 1911 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1451 SetUpScheduler(true); | 1912 SetUpScheduler(true); |
| 1452 | 1913 |
| 1453 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1454 base::TimeDelta::FromMilliseconds(32)); | |
| 1455 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | |
| 1456 base::TimeDelta::FromMilliseconds(32)); | |
| 1457 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1458 base::TimeDelta::FromMilliseconds(1)); | |
| 1459 | |
| 1460 // Disables automatic swap acks so this test can force swap ack throttling | 1914 // Disables automatic swap acks so this test can force swap ack throttling |
| 1461 // to simulate a blocked Browser ui thread. | 1915 // to simulate a blocked Browser ui thread. |
| 1462 scheduler_->SetMaxSwapsPending(1); | 1916 scheduler_->SetMaxSwapsPending(1); |
| 1463 client_->SetAutomaticSwapAck(false); | 1917 client_->SetAutomaticSwapAck(false); |
| 1464 | 1918 |
| 1465 // Start a new commit in main-thread high latency mode and hold off on | 1919 // Start a new commit in main-thread high latency mode and hold off on |
| 1466 // activation. | 1920 // activation. |
| 1467 client_->Reset(); | 1921 client_->Reset(); |
| 1468 EXPECT_FALSE(scheduler_->CommitPending()); | 1922 EXPECT_FALSE(scheduler_->CommitPending()); |
| 1469 scheduler_->SetNeedsCommit(); | 1923 scheduler_->SetNeedsCommit(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1531 // This verifies we don't block commits longer than we need to | 1985 // This verifies we don't block commits longer than we need to |
| 1532 // for performance reasons - not deadlock reasons. | 1986 // for performance reasons - not deadlock reasons. |
| 1533 | 1987 |
| 1534 // Since we are simulating a long commit, set up a client with draw duration | 1988 // Since we are simulating a long commit, set up a client with draw duration |
| 1535 // estimates that prevent skipping main frames to get to low latency mode. | 1989 // estimates that prevent skipping main frames to get to low latency mode. |
| 1536 scheduler_settings_.use_external_begin_frame_source = true; | 1990 scheduler_settings_.use_external_begin_frame_source = true; |
| 1537 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1991 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1538 scheduler_settings_.main_frame_before_activation_enabled = true; | 1992 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1539 SetUpScheduler(true); | 1993 SetUpScheduler(true); |
| 1540 | 1994 |
| 1541 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( | |
| 1542 base::TimeDelta::FromMilliseconds(32)); | |
| 1543 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( | |
| 1544 base::TimeDelta::FromMilliseconds(32)); | |
| 1545 fake_compositor_timing_history_->SetDrawDurationEstimate( | |
| 1546 base::TimeDelta::FromMilliseconds(1)); | |
| 1547 | |
| 1548 // Disables automatic swap acks so this test can force swap ack throttling | 1995 // Disables automatic swap acks so this test can force swap ack throttling |
| 1549 // to simulate a blocked Browser ui thread. | 1996 // to simulate a blocked Browser ui thread. |
| 1550 scheduler_->SetMaxSwapsPending(1); | 1997 scheduler_->SetMaxSwapsPending(1); |
| 1551 client_->SetAutomaticSwapAck(false); | 1998 client_->SetAutomaticSwapAck(false); |
| 1552 | 1999 |
| 1553 // Start a new commit in main-thread high latency mode and hold off on | 2000 // Start a new commit in main-thread high latency mode and hold off on |
| 1554 // activation. | 2001 // activation. |
| 1555 client_->Reset(); | 2002 client_->Reset(); |
| 1556 EXPECT_FALSE(scheduler_->CommitPending()); | 2003 EXPECT_FALSE(scheduler_->CommitPending()); |
| 1557 scheduler_->SetNeedsCommit(); | 2004 scheduler_->SetNeedsCommit(); |
| (...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2955 scheduler_->SetImplLatencyTakesPriority(true); | 3402 scheduler_->SetImplLatencyTakesPriority(true); |
| 2956 scheduler_->SetChildrenNeedBeginFrames(true); | 3403 scheduler_->SetChildrenNeedBeginFrames(true); |
| 2957 | 3404 |
| 2958 EXPECT_SCOPED(AdvanceFrame()); | 3405 EXPECT_SCOPED(AdvanceFrame()); |
| 2959 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 3406 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 2960 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 3407 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |
| 2961 } | 3408 } |
| 2962 | 3409 |
| 2963 } // namespace | 3410 } // namespace |
| 2964 } // namespace cc | 3411 } // namespace cc |
| OLD | NEW |