| 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 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 task_runner().RunPendingTasks(); // Run posted deadline. | 1292 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1293 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); | 1293 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); |
| 1294 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); | 1294 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 1295 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 1295 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 1296 } | 1296 } |
| 1297 | 1297 |
| 1298 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( | 1298 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( |
| 1299 bool expect_send_begin_main_frame) { | 1299 bool expect_send_begin_main_frame) { |
| 1300 // Impl thread hits deadline before commit finishes. | 1300 // Impl thread hits deadline before commit finishes. |
| 1301 scheduler_->SetNeedsCommit(); | 1301 scheduler_->SetNeedsCommit(); |
| 1302 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1302 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1303 EXPECT_SCOPED(AdvanceFrame()); | 1303 EXPECT_SCOPED(AdvanceFrame()); |
| 1304 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1304 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1305 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1305 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1306 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1306 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1307 scheduler_->NotifyBeginMainFrameStarted(); | 1307 scheduler_->NotifyBeginMainFrameStarted(); |
| 1308 scheduler_->NotifyReadyToCommit(); | 1308 scheduler_->NotifyReadyToCommit(); |
| 1309 scheduler_->NotifyReadyToActivate(); | 1309 scheduler_->NotifyReadyToActivate(); |
| 1310 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); | 1310 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); |
| 1311 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); | 1311 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); |
| 1312 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | 1312 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); |
| 1313 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); | 1313 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); |
| 1314 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); | 1314 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); |
| 1315 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1315 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1316 | 1316 |
| 1317 client_->Reset(); | 1317 client_->Reset(); |
| 1318 scheduler_->SetNeedsCommit(); | 1318 scheduler_->SetNeedsCommit(); |
| 1319 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1319 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1320 EXPECT_SCOPED(AdvanceFrame()); | 1320 EXPECT_SCOPED(AdvanceFrame()); |
| 1321 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1321 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1322 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1322 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1323 EXPECT_EQ(expect_send_begin_main_frame, | 1323 EXPECT_EQ(expect_send_begin_main_frame, |
| 1324 scheduler_->MainThreadIsInHighLatencyMode()); | 1324 scheduler_->MainThreadMissedLastDeadline()); |
| 1325 EXPECT_EQ(expect_send_begin_main_frame, | 1325 EXPECT_EQ(expect_send_begin_main_frame, |
| 1326 client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1326 client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1327 } | 1327 } |
| 1328 | 1328 |
| 1329 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { | 1329 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { |
| 1330 scheduler_settings_.use_external_begin_frame_source = true; | 1330 scheduler_settings_.use_external_begin_frame_source = true; |
| 1331 SetUpScheduler(true); | 1331 SetUpScheduler(true); |
| 1332 | 1332 |
| 1333 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1333 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1334 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1334 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1412 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( | 1412 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck_MainThreadMakesDeadline( |
| 1413 bool swap_ack_before_deadline) { | 1413 bool swap_ack_before_deadline) { |
| 1414 // To get into a high latency state, this test disables automatic swap acks. | 1414 // To get into a high latency state, this test disables automatic swap acks. |
| 1415 scheduler_->SetMaxSwapsPending(1); | 1415 scheduler_->SetMaxSwapsPending(1); |
| 1416 client_->SetAutomaticSwapAck(false); | 1416 client_->SetAutomaticSwapAck(false); |
| 1417 | 1417 |
| 1418 // Draw and swap for first BeginFrame | 1418 // Draw and swap for first BeginFrame |
| 1419 client_->Reset(); | 1419 client_->Reset(); |
| 1420 scheduler_->SetNeedsCommit(); | 1420 scheduler_->SetNeedsCommit(); |
| 1421 scheduler_->SetNeedsRedraw(); | 1421 scheduler_->SetNeedsRedraw(); |
| 1422 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1422 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1423 SendNextBeginFrame(); | 1423 SendNextBeginFrame(); |
| 1424 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 4); | 1424 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 4); |
| 1425 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 4); | 1425 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 4); |
| 1426 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1426 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1427 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 3, 4); | 1427 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 3, 4); |
| 1428 | 1428 |
| 1429 client_->Reset(); | 1429 client_->Reset(); |
| 1430 scheduler_->NotifyBeginMainFrameStarted(); | 1430 scheduler_->NotifyBeginMainFrameStarted(); |
| 1431 scheduler_->NotifyReadyToCommit(); | 1431 scheduler_->NotifyReadyToCommit(); |
| 1432 scheduler_->NotifyReadyToActivate(); | 1432 scheduler_->NotifyReadyToActivate(); |
| 1433 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1433 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1434 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1434 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1435 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | 1435 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); |
| 1436 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | 1436 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); |
| 1437 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1437 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1438 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | 1438 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); |
| 1439 | 1439 |
| 1440 // Verify we skip every other frame if the swap ack consistently | 1440 // Verify we skip every other frame if the swap ack consistently |
| 1441 // comes back late. | 1441 // comes back late. |
| 1442 for (int i = 0; i < 10; i++) { | 1442 for (int i = 0; i < 10; i++) { |
| 1443 // Not calling scheduler_->DidSwapBuffersComplete() until after next | 1443 // Not calling scheduler_->DidSwapBuffersComplete() until after next |
| 1444 // BeginImplFrame puts the impl thread in high latency mode. | 1444 // BeginImplFrame puts the impl thread in high latency mode. |
| 1445 client_->Reset(); | 1445 client_->Reset(); |
| 1446 scheduler_->SetNeedsCommit(); | 1446 scheduler_->SetNeedsCommit(); |
| 1447 scheduler_->SetNeedsRedraw(); | 1447 scheduler_->SetNeedsRedraw(); |
| 1448 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1448 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1449 SendNextBeginFrame(); | 1449 SendNextBeginFrame(); |
| 1450 // Verify that we skip the BeginImplFrame | 1450 // Verify that we skip the BeginImplFrame |
| 1451 EXPECT_NO_ACTION(client_); | 1451 EXPECT_NO_ACTION(client_); |
| 1452 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1452 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1453 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1453 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1454 | 1454 |
| 1455 // Verify that we do not perform any actions after we are no longer | 1455 // Verify that we do not perform any actions after we are no longer |
| 1456 // swap throttled. | 1456 // swap throttled. |
| 1457 client_->Reset(); | 1457 client_->Reset(); |
| 1458 if (swap_ack_before_deadline) { | 1458 if (swap_ack_before_deadline) { |
| 1459 // It shouldn't matter if the swap ack comes back before the deadline... | 1459 // It shouldn't matter if the swap ack comes back before the deadline... |
| 1460 scheduler_->DidSwapBuffersComplete(); | 1460 scheduler_->DidSwapBuffersComplete(); |
| 1461 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1461 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1462 } else { | 1462 } else { |
| 1463 // ... or after the deadline. | 1463 // ... or after the deadline. |
| 1464 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1464 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1465 scheduler_->DidSwapBuffersComplete(); | 1465 scheduler_->DidSwapBuffersComplete(); |
| 1466 } | 1466 } |
| 1467 EXPECT_NO_ACTION(client_); | 1467 EXPECT_NO_ACTION(client_); |
| 1468 | 1468 |
| 1469 // Verify that we start the next BeginImplFrame and continue normally | 1469 // Verify that we start the next BeginImplFrame and continue normally |
| 1470 // after having just skipped a BeginImplFrame. | 1470 // after having just skipped a BeginImplFrame. |
| 1471 client_->Reset(); | 1471 client_->Reset(); |
| 1472 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1472 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1473 SendNextBeginFrame(); | 1473 SendNextBeginFrame(); |
| 1474 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1474 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 1475 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 1475 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); |
| 1476 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | 1476 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); |
| 1477 | 1477 |
| 1478 client_->Reset(); | 1478 client_->Reset(); |
| 1479 scheduler_->NotifyBeginMainFrameStarted(); | 1479 scheduler_->NotifyBeginMainFrameStarted(); |
| 1480 scheduler_->NotifyReadyToCommit(); | 1480 scheduler_->NotifyReadyToCommit(); |
| 1481 scheduler_->NotifyReadyToActivate(); | 1481 scheduler_->NotifyReadyToActivate(); |
| 1482 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1482 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 // still expect to recover impl thread latency if there are no commits from | 1546 // still expect to recover impl thread latency if there are no commits from |
| 1547 // the main thread. | 1547 // the main thread. |
| 1548 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1548 auto slow_duration = base::TimeDelta::FromSeconds(1); |
| 1549 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 1549 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); |
| 1550 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1550 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1551 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); | 1551 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); |
| 1552 | 1552 |
| 1553 // Draw and swap for first BeginFrame | 1553 // Draw and swap for first BeginFrame |
| 1554 client_->Reset(); | 1554 client_->Reset(); |
| 1555 scheduler_->SetNeedsRedraw(); | 1555 scheduler_->SetNeedsRedraw(); |
| 1556 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1556 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1557 SendNextBeginFrame(); | 1557 SendNextBeginFrame(); |
| 1558 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | 1558 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); |
| 1559 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1559 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1560 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); | 1560 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); |
| 1561 | 1561 |
| 1562 client_->Reset(); | 1562 client_->Reset(); |
| 1563 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1563 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1564 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1564 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1565 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1565 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 1566 | 1566 |
| 1567 // Verify we skip every other frame if the swap ack consistently | 1567 // Verify we skip every other frame if the swap ack consistently |
| 1568 // comes back late. | 1568 // comes back late. |
| 1569 for (int i = 0; i < 10; i++) { | 1569 for (int i = 0; i < 10; i++) { |
| 1570 // Not calling scheduler_->DidSwapBuffersComplete() until after next | 1570 // Not calling scheduler_->DidSwapBuffersComplete() until after next |
| 1571 // BeginImplFrame puts the impl thread in high latency mode. | 1571 // BeginImplFrame puts the impl thread in high latency mode. |
| 1572 client_->Reset(); | 1572 client_->Reset(); |
| 1573 scheduler_->SetNeedsRedraw(); | 1573 scheduler_->SetNeedsRedraw(); |
| 1574 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1574 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1575 SendNextBeginFrame(); | 1575 SendNextBeginFrame(); |
| 1576 // Verify that we skip the BeginImplFrame | 1576 // Verify that we skip the BeginImplFrame |
| 1577 EXPECT_NO_ACTION(client_); | 1577 EXPECT_NO_ACTION(client_); |
| 1578 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1578 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1579 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1579 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1580 | 1580 |
| 1581 // Verify that we do not perform any actions after we are no longer | 1581 // Verify that we do not perform any actions after we are no longer |
| 1582 // swap throttled. | 1582 // swap throttled. |
| 1583 client_->Reset(); | 1583 client_->Reset(); |
| 1584 scheduler_->DidSwapBuffersComplete(); | 1584 scheduler_->DidSwapBuffersComplete(); |
| 1585 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1585 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1586 EXPECT_NO_ACTION(client_); | 1586 EXPECT_NO_ACTION(client_); |
| 1587 | 1587 |
| 1588 // Verify that we start the next BeginImplFrame and continue normally | 1588 // Verify that we start the next BeginImplFrame and continue normally |
| 1589 // after having just skipped a BeginImplFrame. | 1589 // after having just skipped a BeginImplFrame. |
| 1590 client_->Reset(); | 1590 client_->Reset(); |
| 1591 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1591 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1592 SendNextBeginFrame(); | 1592 SendNextBeginFrame(); |
| 1593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1593 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1594 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1594 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1595 | 1595 |
| 1596 client_->Reset(); | 1596 client_->Reset(); |
| 1597 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1597 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1598 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1598 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 1599 } | 1599 } |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 void SchedulerTest::ImplFrameIsNotSkippedAfterLateSwapAck() { | 1602 void SchedulerTest::ImplFrameIsNotSkippedAfterLateSwapAck() { |
| 1603 // To get into a high latency state, this test disables automatic swap acks. | 1603 // To get into a high latency state, this test disables automatic swap acks. |
| 1604 scheduler_->SetMaxSwapsPending(1); | 1604 scheduler_->SetMaxSwapsPending(1); |
| 1605 client_->SetAutomaticSwapAck(false); | 1605 client_->SetAutomaticSwapAck(false); |
| 1606 | 1606 |
| 1607 // Draw and swap for first BeginFrame | 1607 // Draw and swap for first BeginFrame |
| 1608 client_->Reset(); | 1608 client_->Reset(); |
| 1609 scheduler_->SetNeedsCommit(); | 1609 scheduler_->SetNeedsCommit(); |
| 1610 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1610 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1611 SendNextBeginFrame(); | 1611 SendNextBeginFrame(); |
| 1612 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | 1612 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); |
| 1613 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1613 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1614 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | 1614 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); |
| 1615 | 1615 |
| 1616 client_->Reset(); | 1616 client_->Reset(); |
| 1617 scheduler_->NotifyBeginMainFrameStarted(); | 1617 scheduler_->NotifyBeginMainFrameStarted(); |
| 1618 scheduler_->NotifyReadyToCommit(); | 1618 scheduler_->NotifyReadyToCommit(); |
| 1619 scheduler_->NotifyReadyToActivate(); | 1619 scheduler_->NotifyReadyToActivate(); |
| 1620 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1620 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1621 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1621 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1622 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | 1622 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); |
| 1623 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | 1623 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); |
| 1624 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1624 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1625 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | 1625 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); |
| 1626 | 1626 |
| 1627 // Verify impl thread consistently operates in high latency mode | 1627 // Verify impl thread consistently operates in high latency mode |
| 1628 // without skipping any frames. | 1628 // without skipping any frames. |
| 1629 for (int i = 0; i < 10; i++) { | 1629 for (int i = 0; i < 10; i++) { |
| 1630 // Not calling scheduler_->DidSwapBuffersComplete() until after next frame | 1630 // Not calling scheduler_->DidSwapBuffersComplete() until after next frame |
| 1631 // puts the impl thread in high latency mode. | 1631 // puts the impl thread in high latency mode. |
| 1632 client_->Reset(); | 1632 client_->Reset(); |
| 1633 scheduler_->SetNeedsCommit(); | 1633 scheduler_->SetNeedsCommit(); |
| 1634 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1634 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1635 SendNextBeginFrame(); | 1635 SendNextBeginFrame(); |
| 1636 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 1636 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 1637 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1637 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1638 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1638 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1639 | 1639 |
| 1640 client_->Reset(); | 1640 client_->Reset(); |
| 1641 scheduler_->DidSwapBuffersComplete(); | 1641 scheduler_->DidSwapBuffersComplete(); |
| 1642 scheduler_->NotifyBeginMainFrameStarted(); | 1642 scheduler_->NotifyBeginMainFrameStarted(); |
| 1643 scheduler_->NotifyReadyToCommit(); | 1643 scheduler_->NotifyReadyToCommit(); |
| 1644 scheduler_->NotifyReadyToActivate(); | 1644 scheduler_->NotifyReadyToActivate(); |
| 1645 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1645 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1646 | 1646 |
| 1647 // Verify that we don't skip the actions of the BeginImplFrame | 1647 // Verify that we don't skip the actions of the BeginImplFrame |
| 1648 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); | 1648 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1709 SetUpScheduler(true); | 1709 SetUpScheduler(true); |
| 1710 | 1710 |
| 1711 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1711 auto slow_duration = base::TimeDelta::FromSeconds(1); |
| 1712 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 1712 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); |
| 1713 | 1713 |
| 1714 // To get into a high latency state, this test disables automatic swap acks. | 1714 // To get into a high latency state, this test disables automatic swap acks. |
| 1715 scheduler_->SetMaxSwapsPending(1); | 1715 scheduler_->SetMaxSwapsPending(1); |
| 1716 client_->SetAutomaticSwapAck(false); | 1716 client_->SetAutomaticSwapAck(false); |
| 1717 | 1717 |
| 1718 // Impl thread hits deadline before commit finishes to make | 1718 // Impl thread hits deadline before commit finishes to make |
| 1719 // MainThreadIsInHighLatencyMode true | 1719 // MainThreadMissedLastDeadline true |
| 1720 client_->Reset(); | 1720 client_->Reset(); |
| 1721 scheduler_->SetNeedsCommit(); | 1721 scheduler_->SetNeedsCommit(); |
| 1722 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1722 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1723 EXPECT_SCOPED(AdvanceFrame()); | 1723 EXPECT_SCOPED(AdvanceFrame()); |
| 1724 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1724 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1725 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1725 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1726 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1726 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1727 scheduler_->NotifyBeginMainFrameStarted(); | 1727 scheduler_->NotifyBeginMainFrameStarted(); |
| 1728 scheduler_->NotifyReadyToCommit(); | 1728 scheduler_->NotifyReadyToCommit(); |
| 1729 scheduler_->NotifyReadyToActivate(); | 1729 scheduler_->NotifyReadyToActivate(); |
| 1730 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1730 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1731 | 1731 |
| 1732 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); | 1732 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); |
| 1733 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); | 1733 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); |
| 1734 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | 1734 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); |
| 1735 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); | 1735 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); |
| 1736 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); | 1736 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); |
| 1737 | 1737 |
| 1738 // Draw and swap for first commit, start second commit. | 1738 // Draw and swap for first commit, start second commit. |
| 1739 client_->Reset(); | 1739 client_->Reset(); |
| 1740 scheduler_->SetNeedsCommit(); | 1740 scheduler_->SetNeedsCommit(); |
| 1741 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1741 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1742 EXPECT_SCOPED(AdvanceFrame()); | 1742 EXPECT_SCOPED(AdvanceFrame()); |
| 1743 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1743 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1744 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1744 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1745 scheduler_->NotifyBeginMainFrameStarted(); | 1745 scheduler_->NotifyBeginMainFrameStarted(); |
| 1746 scheduler_->NotifyReadyToCommit(); | 1746 scheduler_->NotifyReadyToCommit(); |
| 1747 scheduler_->NotifyReadyToActivate(); | 1747 scheduler_->NotifyReadyToActivate(); |
| 1748 | 1748 |
| 1749 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); | 1749 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); |
| 1750 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 6); | 1750 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 6); |
| 1751 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 6); | 1751 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 6); |
| 1752 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 6); | 1752 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 6); |
| 1753 EXPECT_ACTION("ScheduledActionCommit", client_, 4, 6); | 1753 EXPECT_ACTION("ScheduledActionCommit", client_, 4, 6); |
| 1754 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 5, 6); | 1754 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 5, 6); |
| 1755 | 1755 |
| 1756 // Don't call scheduler_->DidSwapBuffersComplete() until after next frame | 1756 // Don't call scheduler_->DidSwapBuffersComplete() until after next frame |
| 1757 // to put the impl thread in a high latency mode. | 1757 // to put the impl thread in a high latency mode. |
| 1758 client_->Reset(); | 1758 client_->Reset(); |
| 1759 scheduler_->SetNeedsCommit(); | 1759 scheduler_->SetNeedsCommit(); |
| 1760 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1760 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1761 EXPECT_SCOPED(AdvanceFrame()); | 1761 EXPECT_SCOPED(AdvanceFrame()); |
| 1762 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1762 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1763 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1763 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1764 | 1764 |
| 1765 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1765 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1766 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1766 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1767 // Note: BeginMainFrame and swap are skipped here because of | 1767 // Note: BeginMainFrame and swap are skipped here because of |
| 1768 // swap ack backpressure, not because of latency recovery. | 1768 // swap ack backpressure, not because of latency recovery. |
| 1769 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1769 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1770 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 1770 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| 1771 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1771 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1772 EXPECT_TRUE(scheduler_->WasSwapThrottledAtLastBeginFrame()); | 1772 EXPECT_TRUE(scheduler_->WasSwapThrottledAtLastBeginFrame()); |
| 1773 | 1773 |
| 1774 // Lower estimates so that the scheduler will attempt latency recovery. | 1774 // Lower estimates so that the scheduler will attempt latency recovery. |
| 1775 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1775 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1776 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1776 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); |
| 1777 | 1777 |
| 1778 // Now that both threads are in a high latency mode, make sure we | 1778 // Now that both threads are in a high latency mode, make sure we |
| 1779 // skip the BeginMainFrame, then the BeginImplFrame, but not both | 1779 // skip the BeginMainFrame, then the BeginImplFrame, but not both |
| 1780 // at the same time. | 1780 // at the same time. |
| 1781 | 1781 |
| 1782 // Verify we skip BeginMainFrame first. | 1782 // Verify we skip BeginMainFrame first. |
| 1783 client_->Reset(); | 1783 client_->Reset(); |
| 1784 // Previous commit request is still outstanding. | 1784 // Previous commit request is still outstanding. |
| 1785 EXPECT_TRUE(scheduler_->NeedsCommit()); | 1785 EXPECT_TRUE(scheduler_->NeedsCommit()); |
| 1786 SendNextBeginFrame(); | 1786 SendNextBeginFrame(); |
| 1787 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1787 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1788 EXPECT_TRUE(scheduler_->WasSwapThrottledAtLastBeginFrame()); | 1788 EXPECT_TRUE(scheduler_->WasSwapThrottledAtLastBeginFrame()); |
| 1789 scheduler_->DidSwapBuffersComplete(); | 1789 scheduler_->DidSwapBuffersComplete(); |
| 1790 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1790 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1791 | 1791 |
| 1792 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1792 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1793 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1793 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 1794 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 1794 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); |
| 1795 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); | 1795 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); |
| 1796 | 1796 |
| 1797 // Verify we skip the BeginImplFrame second. | 1797 // Verify we skip the BeginImplFrame second. |
| 1798 client_->Reset(); | 1798 client_->Reset(); |
| 1799 // Previous commit request is still outstanding. | 1799 // Previous commit request is still outstanding. |
| 1800 EXPECT_TRUE(scheduler_->NeedsCommit()); | 1800 EXPECT_TRUE(scheduler_->NeedsCommit()); |
| 1801 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1801 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1802 SendNextBeginFrame(); | 1802 SendNextBeginFrame(); |
| 1803 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1803 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1804 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1804 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1805 scheduler_->DidSwapBuffersComplete(); | 1805 scheduler_->DidSwapBuffersComplete(); |
| 1806 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1806 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1807 | 1807 |
| 1808 EXPECT_NO_ACTION(client_); | 1808 EXPECT_NO_ACTION(client_); |
| 1809 | 1809 |
| 1810 // Then verify we operate in a low latency mode. | 1810 // Then verify we operate in a low latency mode. |
| 1811 client_->Reset(); | 1811 client_->Reset(); |
| 1812 // Previous commit request is still outstanding. | 1812 // Previous commit request is still outstanding. |
| 1813 EXPECT_TRUE(scheduler_->NeedsCommit()); | 1813 EXPECT_TRUE(scheduler_->NeedsCommit()); |
| 1814 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1814 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1815 SendNextBeginFrame(); | 1815 SendNextBeginFrame(); |
| 1816 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1816 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1817 scheduler_->NotifyBeginMainFrameStarted(); | 1817 scheduler_->NotifyBeginMainFrameStarted(); |
| 1818 scheduler_->NotifyReadyToCommit(); | 1818 scheduler_->NotifyReadyToCommit(); |
| 1819 scheduler_->NotifyReadyToActivate(); | 1819 scheduler_->NotifyReadyToActivate(); |
| 1820 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1820 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1821 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1821 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1822 scheduler_->DidSwapBuffersComplete(); | 1822 scheduler_->DidSwapBuffersComplete(); |
| 1823 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1823 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1824 | 1824 |
| 1825 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); | 1825 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); |
| 1826 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 6); | 1826 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 6); |
| 1827 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 6); | 1827 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 6); |
| 1828 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 6); | 1828 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 6); |
| 1829 EXPECT_ACTION("ScheduledActionAnimate", client_, 4, 6); | 1829 EXPECT_ACTION("ScheduledActionAnimate", client_, 4, 6); |
| 1830 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 5, 6); | 1830 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 5, 6); |
| 1831 } | 1831 } |
| 1832 | 1832 |
| 1833 TEST_F( | 1833 TEST_F( |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3402 scheduler_->SetImplLatencyTakesPriority(true); | 3402 scheduler_->SetImplLatencyTakesPriority(true); |
| 3403 scheduler_->SetChildrenNeedBeginFrames(true); | 3403 scheduler_->SetChildrenNeedBeginFrames(true); |
| 3404 | 3404 |
| 3405 EXPECT_SCOPED(AdvanceFrame()); | 3405 EXPECT_SCOPED(AdvanceFrame()); |
| 3406 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 3406 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 3407 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); |
| 3408 } | 3408 } |
| 3409 | 3409 |
| 3410 } // namespace | 3410 } // namespace |
| 3411 } // namespace cc | 3411 } // namespace cc |
| OLD | NEW |