| 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 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1324 task_runner().RunPendingTasks(); // Run posted deadline. | 1324 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1325 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); | 1325 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); |
| 1326 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); | 1326 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 1327 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 1327 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 1328 } | 1328 } |
| 1329 | 1329 |
| 1330 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( | 1330 void SchedulerTest::CheckMainFrameSkippedAfterLateCommit( |
| 1331 bool expect_send_begin_main_frame) { | 1331 bool expect_send_begin_main_frame) { |
| 1332 // Impl thread hits deadline before commit finishes. | 1332 // Impl thread hits deadline before commit finishes. |
| 1333 scheduler_->SetNeedsCommit(); | 1333 scheduler_->SetNeedsCommit(); |
| 1334 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1334 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1335 EXPECT_SCOPED(AdvanceFrame()); | 1335 EXPECT_SCOPED(AdvanceFrame()); |
| 1336 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1336 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1337 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1337 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1338 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1338 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1339 scheduler_->NotifyBeginMainFrameStarted(); | 1339 scheduler_->NotifyBeginMainFrameStarted(); |
| 1340 scheduler_->NotifyReadyToCommit(); | 1340 scheduler_->NotifyReadyToCommit(); |
| 1341 scheduler_->NotifyReadyToActivate(); | 1341 scheduler_->NotifyReadyToActivate(); |
| 1342 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); | 1342 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); |
| 1343 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); | 1343 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); |
| 1344 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | 1344 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); |
| 1345 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); | 1345 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); |
| 1346 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); | 1346 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); |
| 1347 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1347 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1348 | 1348 |
| 1349 client_->Reset(); | 1349 client_->Reset(); |
| 1350 scheduler_->SetNeedsCommit(); | 1350 scheduler_->SetNeedsCommit(); |
| 1351 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1351 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1352 EXPECT_SCOPED(AdvanceFrame()); | 1352 EXPECT_SCOPED(AdvanceFrame()); |
| 1353 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1353 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1354 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1354 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1355 EXPECT_EQ(expect_send_begin_main_frame, | 1355 EXPECT_EQ(expect_send_begin_main_frame, |
| 1356 scheduler_->MainThreadIsInHighLatencyMode()); | 1356 scheduler_->MainThreadMissedLastDeadline()); |
| 1357 EXPECT_EQ(expect_send_begin_main_frame, | 1357 EXPECT_EQ(expect_send_begin_main_frame, |
| 1358 client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1358 client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { | 1361 TEST_F(SchedulerTest, MainFrameSkippedAfterLateCommit) { |
| 1362 scheduler_settings_.use_external_begin_frame_source = true; | 1362 scheduler_settings_.use_external_begin_frame_source = true; |
| 1363 SetUpScheduler(true); | 1363 SetUpScheduler(true); |
| 1364 | 1364 |
| 1365 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1365 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1366 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1366 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( | 1444 void SchedulerTest::ImplFrameSkippedAfterLateSwapAck( |
| 1445 bool swap_ack_before_deadline) { | 1445 bool swap_ack_before_deadline) { |
| 1446 // To get into a high latency state, this test disables automatic swap acks. | 1446 // To get into a high latency state, this test disables automatic swap acks. |
| 1447 scheduler_->SetMaxSwapsPending(1); | 1447 scheduler_->SetMaxSwapsPending(1); |
| 1448 client_->SetAutomaticSwapAck(false); | 1448 client_->SetAutomaticSwapAck(false); |
| 1449 | 1449 |
| 1450 // Draw and swap for first BeginFrame | 1450 // Draw and swap for first BeginFrame |
| 1451 client_->Reset(); | 1451 client_->Reset(); |
| 1452 scheduler_->SetNeedsCommit(); | 1452 scheduler_->SetNeedsCommit(); |
| 1453 scheduler_->SetNeedsRedraw(); | 1453 scheduler_->SetNeedsRedraw(); |
| 1454 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1454 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1455 SendNextBeginFrame(); | 1455 SendNextBeginFrame(); |
| 1456 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 4); | 1456 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 4); |
| 1457 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 4); | 1457 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 4); |
| 1458 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1458 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1459 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 3, 4); | 1459 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 3, 4); |
| 1460 | 1460 |
| 1461 client_->Reset(); | 1461 client_->Reset(); |
| 1462 scheduler_->NotifyBeginMainFrameStarted(); | 1462 scheduler_->NotifyBeginMainFrameStarted(); |
| 1463 scheduler_->NotifyReadyToCommit(); | 1463 scheduler_->NotifyReadyToCommit(); |
| 1464 scheduler_->NotifyReadyToActivate(); | 1464 scheduler_->NotifyReadyToActivate(); |
| 1465 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1465 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1466 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1466 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1467 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | 1467 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); |
| 1468 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | 1468 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); |
| 1469 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1469 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1470 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | 1470 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); |
| 1471 | 1471 |
| 1472 // Verify we skip every other frame if the swap ack consistently | 1472 // Verify we skip every other frame if the swap ack consistently |
| 1473 // comes back late. | 1473 // comes back late. |
| 1474 for (int i = 0; i < 10; i++) { | 1474 for (int i = 0; i < 10; i++) { |
| 1475 // Not calling scheduler_->DidSwapBuffersComplete() until after next | 1475 // Not calling scheduler_->DidSwapBuffersComplete() until after next |
| 1476 // BeginImplFrame puts the impl thread in high latency mode. | 1476 // BeginImplFrame puts the impl thread in high latency mode. |
| 1477 client_->Reset(); | 1477 client_->Reset(); |
| 1478 scheduler_->SetNeedsCommit(); | 1478 scheduler_->SetNeedsCommit(); |
| 1479 scheduler_->SetNeedsRedraw(); | 1479 scheduler_->SetNeedsRedraw(); |
| 1480 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1480 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1481 SendNextBeginFrame(); | 1481 SendNextBeginFrame(); |
| 1482 // Verify that we skip the BeginImplFrame | 1482 // Verify that we skip the BeginImplFrame |
| 1483 EXPECT_NO_ACTION(client_); | 1483 EXPECT_NO_ACTION(client_); |
| 1484 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1484 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1485 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1485 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1486 | 1486 |
| 1487 // Verify that we do not perform any actions after we are no longer | 1487 // Verify that we do not perform any actions after we are no longer |
| 1488 // swap throttled. | 1488 // swap throttled. |
| 1489 client_->Reset(); | 1489 client_->Reset(); |
| 1490 if (swap_ack_before_deadline) { | 1490 if (swap_ack_before_deadline) { |
| 1491 // It shouldn't matter if the swap ack comes back before the deadline... | 1491 // It shouldn't matter if the swap ack comes back before the deadline... |
| 1492 scheduler_->DidSwapBuffersComplete(); | 1492 scheduler_->DidSwapBuffersComplete(); |
| 1493 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1493 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1494 } else { | 1494 } else { |
| 1495 // ... or after the deadline. | 1495 // ... or after the deadline. |
| 1496 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1496 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1497 scheduler_->DidSwapBuffersComplete(); | 1497 scheduler_->DidSwapBuffersComplete(); |
| 1498 } | 1498 } |
| 1499 EXPECT_NO_ACTION(client_); | 1499 EXPECT_NO_ACTION(client_); |
| 1500 | 1500 |
| 1501 // Verify that we start the next BeginImplFrame and continue normally | 1501 // Verify that we start the next BeginImplFrame and continue normally |
| 1502 // after having just skipped a BeginImplFrame. | 1502 // after having just skipped a BeginImplFrame. |
| 1503 client_->Reset(); | 1503 client_->Reset(); |
| 1504 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1504 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1505 SendNextBeginFrame(); | 1505 SendNextBeginFrame(); |
| 1506 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1506 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 1507 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 1507 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); |
| 1508 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | 1508 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); |
| 1509 | 1509 |
| 1510 client_->Reset(); | 1510 client_->Reset(); |
| 1511 scheduler_->NotifyBeginMainFrameStarted(); | 1511 scheduler_->NotifyBeginMainFrameStarted(); |
| 1512 scheduler_->NotifyReadyToCommit(); | 1512 scheduler_->NotifyReadyToCommit(); |
| 1513 scheduler_->NotifyReadyToActivate(); | 1513 scheduler_->NotifyReadyToActivate(); |
| 1514 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1514 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 // still expect to recover impl thread latency if there are no commits from | 1575 // still expect to recover impl thread latency if there are no commits from |
| 1576 // the main thread. | 1576 // the main thread. |
| 1577 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1577 auto slow_duration = base::TimeDelta::FromSeconds(1); |
| 1578 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 1578 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); |
| 1579 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1579 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1580 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); | 1580 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); |
| 1581 | 1581 |
| 1582 // Draw and swap for first BeginFrame | 1582 // Draw and swap for first BeginFrame |
| 1583 client_->Reset(); | 1583 client_->Reset(); |
| 1584 scheduler_->SetNeedsRedraw(); | 1584 scheduler_->SetNeedsRedraw(); |
| 1585 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1585 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1586 SendNextBeginFrame(); | 1586 SendNextBeginFrame(); |
| 1587 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | 1587 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); |
| 1588 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1588 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1589 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); | 1589 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 3); |
| 1590 | 1590 |
| 1591 client_->Reset(); | 1591 client_->Reset(); |
| 1592 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1592 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1593 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1593 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1594 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1594 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 1595 | 1595 |
| 1596 // Verify we skip every other frame if the swap ack consistently | 1596 // Verify we skip every other frame if the swap ack consistently |
| 1597 // comes back late. | 1597 // comes back late. |
| 1598 for (int i = 0; i < 10; i++) { | 1598 for (int i = 0; i < 10; i++) { |
| 1599 // Not calling scheduler_->DidSwapBuffersComplete() until after next | 1599 // Not calling scheduler_->DidSwapBuffersComplete() until after next |
| 1600 // BeginImplFrame puts the impl thread in high latency mode. | 1600 // BeginImplFrame puts the impl thread in high latency mode. |
| 1601 client_->Reset(); | 1601 client_->Reset(); |
| 1602 scheduler_->SetNeedsRedraw(); | 1602 scheduler_->SetNeedsRedraw(); |
| 1603 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1603 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1604 SendNextBeginFrame(); | 1604 SendNextBeginFrame(); |
| 1605 // Verify that we skip the BeginImplFrame | 1605 // Verify that we skip the BeginImplFrame |
| 1606 EXPECT_NO_ACTION(client_); | 1606 EXPECT_NO_ACTION(client_); |
| 1607 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1607 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1608 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1608 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1609 | 1609 |
| 1610 // Verify that we do not perform any actions after we are no longer | 1610 // Verify that we do not perform any actions after we are no longer |
| 1611 // swap throttled. | 1611 // swap throttled. |
| 1612 client_->Reset(); | 1612 client_->Reset(); |
| 1613 scheduler_->DidSwapBuffersComplete(); | 1613 scheduler_->DidSwapBuffersComplete(); |
| 1614 EXPECT_NO_ACTION(client_); | 1614 EXPECT_NO_ACTION(client_); |
| 1615 | 1615 |
| 1616 // Verify that we start the next BeginImplFrame and continue normally | 1616 // Verify that we start the next BeginImplFrame and continue normally |
| 1617 // after having just skipped a BeginImplFrame. | 1617 // after having just skipped a BeginImplFrame. |
| 1618 client_->Reset(); | 1618 client_->Reset(); |
| 1619 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1619 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1620 SendNextBeginFrame(); | 1620 SendNextBeginFrame(); |
| 1621 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1621 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1622 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1622 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1623 | 1623 |
| 1624 client_->Reset(); | 1624 client_->Reset(); |
| 1625 // Deadline should be immediate. | 1625 // Deadline should be immediate. |
| 1626 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1626 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1627 task_runner().RunUntilTime(now_src_->NowTicks()); | 1627 task_runner().RunUntilTime(now_src_->NowTicks()); |
| 1628 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1628 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1629 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1629 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
| 1630 } | 1630 } |
| 1631 } | 1631 } |
| 1632 | 1632 |
| 1633 void SchedulerTest::ImplFrameIsNotSkippedAfterLateSwapAck() { | 1633 void SchedulerTest::ImplFrameIsNotSkippedAfterLateSwapAck() { |
| 1634 // To get into a high latency state, this test disables automatic swap acks. | 1634 // To get into a high latency state, this test disables automatic swap acks. |
| 1635 scheduler_->SetMaxSwapsPending(1); | 1635 scheduler_->SetMaxSwapsPending(1); |
| 1636 client_->SetAutomaticSwapAck(false); | 1636 client_->SetAutomaticSwapAck(false); |
| 1637 | 1637 |
| 1638 // Draw and swap for first BeginFrame | 1638 // Draw and swap for first BeginFrame |
| 1639 client_->Reset(); | 1639 client_->Reset(); |
| 1640 scheduler_->SetNeedsCommit(); | 1640 scheduler_->SetNeedsCommit(); |
| 1641 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1641 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1642 SendNextBeginFrame(); | 1642 SendNextBeginFrame(); |
| 1643 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); | 1643 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 3); |
| 1644 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); | 1644 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 3); |
| 1645 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); | 1645 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 3); |
| 1646 | 1646 |
| 1647 client_->Reset(); | 1647 client_->Reset(); |
| 1648 scheduler_->NotifyBeginMainFrameStarted(); | 1648 scheduler_->NotifyBeginMainFrameStarted(); |
| 1649 scheduler_->NotifyReadyToCommit(); | 1649 scheduler_->NotifyReadyToCommit(); |
| 1650 scheduler_->NotifyReadyToActivate(); | 1650 scheduler_->NotifyReadyToActivate(); |
| 1651 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1651 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1652 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1652 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1653 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); | 1653 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 4); |
| 1654 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); | 1654 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 4); |
| 1655 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); | 1655 EXPECT_ACTION("ScheduledActionAnimate", client_, 2, 4); |
| 1656 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); | 1656 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 4); |
| 1657 | 1657 |
| 1658 // Verify impl thread consistently operates in high latency mode | 1658 // Verify impl thread consistently operates in high latency mode |
| 1659 // without skipping any frames. | 1659 // without skipping any frames. |
| 1660 for (int i = 0; i < 10; i++) { | 1660 for (int i = 0; i < 10; i++) { |
| 1661 // Not calling scheduler_->DidSwapBuffersComplete() until after next frame | 1661 // Not calling scheduler_->DidSwapBuffersComplete() until after next frame |
| 1662 // puts the impl thread in high latency mode. | 1662 // puts the impl thread in high latency mode. |
| 1663 client_->Reset(); | 1663 client_->Reset(); |
| 1664 scheduler_->SetNeedsCommit(); | 1664 scheduler_->SetNeedsCommit(); |
| 1665 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1665 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1666 SendNextBeginFrame(); | 1666 SendNextBeginFrame(); |
| 1667 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); | 1667 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); |
| 1668 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1668 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
| 1669 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1669 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1670 | 1670 |
| 1671 client_->Reset(); | 1671 client_->Reset(); |
| 1672 scheduler_->DidSwapBuffersComplete(); | 1672 scheduler_->DidSwapBuffersComplete(); |
| 1673 scheduler_->NotifyBeginMainFrameStarted(); | 1673 scheduler_->NotifyBeginMainFrameStarted(); |
| 1674 scheduler_->NotifyReadyToCommit(); | 1674 scheduler_->NotifyReadyToCommit(); |
| 1675 scheduler_->NotifyReadyToActivate(); | 1675 scheduler_->NotifyReadyToActivate(); |
| 1676 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1676 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1677 | 1677 |
| 1678 // Verify that we don't skip the actions of the BeginImplFrame | 1678 // Verify that we don't skip the actions of the BeginImplFrame |
| 1679 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); | 1679 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 0, 5); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1740 SetUpScheduler(true); | 1740 SetUpScheduler(true); |
| 1741 | 1741 |
| 1742 auto slow_duration = base::TimeDelta::FromSeconds(1); | 1742 auto slow_duration = base::TimeDelta::FromSeconds(1); |
| 1743 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); | 1743 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); |
| 1744 | 1744 |
| 1745 // To get into a high latency state, this test disables automatic swap acks. | 1745 // To get into a high latency state, this test disables automatic swap acks. |
| 1746 scheduler_->SetMaxSwapsPending(1); | 1746 scheduler_->SetMaxSwapsPending(1); |
| 1747 client_->SetAutomaticSwapAck(false); | 1747 client_->SetAutomaticSwapAck(false); |
| 1748 | 1748 |
| 1749 // Impl thread hits deadline before commit finishes to make | 1749 // Impl thread hits deadline before commit finishes to make |
| 1750 // MainThreadIsInHighLatencyMode true | 1750 // MainThreadMissedLastDeadline true |
| 1751 client_->Reset(); | 1751 client_->Reset(); |
| 1752 scheduler_->SetNeedsCommit(); | 1752 scheduler_->SetNeedsCommit(); |
| 1753 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1753 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1754 EXPECT_SCOPED(AdvanceFrame()); | 1754 EXPECT_SCOPED(AdvanceFrame()); |
| 1755 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1755 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1756 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1756 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1757 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1757 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1758 scheduler_->NotifyBeginMainFrameStarted(); | 1758 scheduler_->NotifyBeginMainFrameStarted(); |
| 1759 scheduler_->NotifyReadyToCommit(); | 1759 scheduler_->NotifyReadyToCommit(); |
| 1760 scheduler_->NotifyReadyToActivate(); | 1760 scheduler_->NotifyReadyToActivate(); |
| 1761 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1761 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1762 | 1762 |
| 1763 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); | 1763 EXPECT_ACTION("SetNeedsBeginFrames(true)", client_, 0, 5); |
| 1764 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); | 1764 EXPECT_ACTION("WillBeginImplFrame", client_, 1, 5); |
| 1765 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); | 1765 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 5); |
| 1766 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); | 1766 EXPECT_ACTION("ScheduledActionCommit", client_, 3, 5); |
| 1767 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); | 1767 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 4, 5); |
| 1768 | 1768 |
| 1769 // Draw and swap for first commit, start second commit. | 1769 // Draw and swap for first commit, start second commit. |
| 1770 client_->Reset(); | 1770 client_->Reset(); |
| 1771 scheduler_->SetNeedsCommit(); | 1771 scheduler_->SetNeedsCommit(); |
| 1772 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1772 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1773 EXPECT_SCOPED(AdvanceFrame()); | 1773 EXPECT_SCOPED(AdvanceFrame()); |
| 1774 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1774 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1775 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1775 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1776 scheduler_->NotifyBeginMainFrameStarted(); | 1776 scheduler_->NotifyBeginMainFrameStarted(); |
| 1777 scheduler_->NotifyReadyToCommit(); | 1777 scheduler_->NotifyReadyToCommit(); |
| 1778 scheduler_->NotifyReadyToActivate(); | 1778 scheduler_->NotifyReadyToActivate(); |
| 1779 | 1779 |
| 1780 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); | 1780 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); |
| 1781 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 6); | 1781 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 6); |
| 1782 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 6); | 1782 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 2, 6); |
| 1783 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 6); | 1783 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 3, 6); |
| 1784 EXPECT_ACTION("ScheduledActionCommit", client_, 4, 6); | 1784 EXPECT_ACTION("ScheduledActionCommit", client_, 4, 6); |
| 1785 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 5, 6); | 1785 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 5, 6); |
| 1786 | 1786 |
| 1787 // Don't call scheduler_->DidSwapBuffersComplete() until after next frame | 1787 // Don't call scheduler_->DidSwapBuffersComplete() until after next frame |
| 1788 // to put the impl thread in a high latency mode. | 1788 // to put the impl thread in a high latency mode. |
| 1789 client_->Reset(); | 1789 client_->Reset(); |
| 1790 scheduler_->SetNeedsCommit(); | 1790 scheduler_->SetNeedsCommit(); |
| 1791 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1791 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1792 EXPECT_TRUE(scheduler_->SwapThrottled()); | |
| 1793 EXPECT_SCOPED(AdvanceFrame()); | 1792 EXPECT_SCOPED(AdvanceFrame()); |
| 1794 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1793 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1795 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1794 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1796 | 1795 |
| 1797 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1796 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
| 1798 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1797 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
| 1799 // Note: BeginMainFrame and swap are skipped here because of | 1798 // Note: BeginMainFrame and swap are skipped here because of |
| 1800 // swap ack backpressure, not because of latency recovery. | 1799 // swap ack backpressure, not because of latency recovery. |
| 1801 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); | 1800 EXPECT_FALSE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1802 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); | 1801 EXPECT_FALSE(client_->HasAction("ScheduledActionDrawAndSwapIfPossible")); |
| 1803 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1802 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1804 | 1803 |
| 1805 // Lower estimates so that the scheduler will attempt latency recovery. | 1804 // Lower estimates so that the scheduler will attempt latency recovery. |
| 1806 auto fast_duration = base::TimeDelta::FromMilliseconds(1); | 1805 auto fast_duration = base::TimeDelta::FromMilliseconds(1); |
| 1807 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); | 1806 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); |
| 1808 | 1807 |
| 1809 // Now that both threads are in a high latency mode, make sure we | 1808 // Now that both threads are in a high latency mode, make sure we |
| 1810 // skip the BeginMainFrame, then the BeginImplFrame, but not both | 1809 // skip the BeginMainFrame, then the BeginImplFrame, but not both |
| 1811 // at the same time. | 1810 // at the same time. |
| 1812 | 1811 |
| 1813 // Verify we skip BeginMainFrame first. | 1812 // Verify we skip BeginMainFrame first. |
| 1814 client_->Reset(); | 1813 client_->Reset(); |
| 1815 // Previous commit request is still outstanding. | 1814 // Previous commit request is still outstanding. |
| 1816 EXPECT_TRUE(scheduler_->NeedsCommit()); | 1815 EXPECT_TRUE(scheduler_->NeedsCommit()); |
| 1817 EXPECT_TRUE(scheduler_->SwapThrottled()); | 1816 EXPECT_TRUE(scheduler_->SwapThrottled()); |
| 1818 SendNextBeginFrame(); | 1817 SendNextBeginFrame(); |
| 1819 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1818 EXPECT_TRUE(scheduler_->MainThreadMissedLastDeadline()); |
| 1820 scheduler_->DidSwapBuffersComplete(); | 1819 scheduler_->DidSwapBuffersComplete(); |
| 1821 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1820 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1822 | 1821 |
| 1823 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1822 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1824 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); | 1823 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 3); |
| 1825 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); | 1824 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 3); |
| 1826 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); | 1825 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 2, 3); |
| 1827 | 1826 |
| 1828 // Verify we skip the BeginImplFrame second. | 1827 // Verify we skip the BeginImplFrame second. |
| 1829 client_->Reset(); | 1828 client_->Reset(); |
| 1830 // Previous commit request is still outstanding. | 1829 // Previous commit request is still outstanding. |
| 1831 EXPECT_TRUE(scheduler_->NeedsCommit()); | 1830 EXPECT_TRUE(scheduler_->NeedsCommit()); |
| 1832 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1831 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1833 SendNextBeginFrame(); | 1832 SendNextBeginFrame(); |
| 1834 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1833 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1835 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1834 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1836 scheduler_->DidSwapBuffersComplete(); | 1835 scheduler_->DidSwapBuffersComplete(); |
| 1837 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1836 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1838 | 1837 |
| 1839 EXPECT_NO_ACTION(client_); | 1838 EXPECT_NO_ACTION(client_); |
| 1840 | 1839 |
| 1841 // Then verify we operate in a low latency mode. | 1840 // Then verify we operate in a low latency mode. |
| 1842 client_->Reset(); | 1841 client_->Reset(); |
| 1843 // Previous commit request is still outstanding. | 1842 // Previous commit request is still outstanding. |
| 1844 EXPECT_TRUE(scheduler_->NeedsCommit()); | 1843 EXPECT_TRUE(scheduler_->NeedsCommit()); |
| 1845 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1844 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1846 SendNextBeginFrame(); | 1845 SendNextBeginFrame(); |
| 1847 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1846 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1848 scheduler_->NotifyBeginMainFrameStarted(); | 1847 scheduler_->NotifyBeginMainFrameStarted(); |
| 1849 scheduler_->NotifyReadyToCommit(); | 1848 scheduler_->NotifyReadyToCommit(); |
| 1850 scheduler_->NotifyReadyToActivate(); | 1849 scheduler_->NotifyReadyToActivate(); |
| 1851 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 1850 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
| 1852 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1851 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1853 scheduler_->DidSwapBuffersComplete(); | 1852 scheduler_->DidSwapBuffersComplete(); |
| 1854 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1853 EXPECT_FALSE(scheduler_->MainThreadMissedLastDeadline()); |
| 1855 | 1854 |
| 1856 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); | 1855 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 6); |
| 1857 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 6); | 1856 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 6); |
| 1858 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 6); | 1857 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 6); |
| 1859 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 6); | 1858 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 3, 6); |
| 1860 EXPECT_ACTION("ScheduledActionAnimate", client_, 4, 6); | 1859 EXPECT_ACTION("ScheduledActionAnimate", client_, 4, 6); |
| 1861 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 5, 6); | 1860 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 5, 6); |
| 1862 } | 1861 } |
| 1863 | 1862 |
| 1864 TEST_F( | 1863 TEST_F( |
| (...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3493 scheduler_->SetImplLatencyTakesPriority(true); | 3492 scheduler_->SetImplLatencyTakesPriority(true); |
| 3494 scheduler_->SetChildrenNeedBeginFrames(true); | 3493 scheduler_->SetChildrenNeedBeginFrames(true); |
| 3495 | 3494 |
| 3496 EXPECT_SCOPED(AdvanceFrame()); | 3495 EXPECT_SCOPED(AdvanceFrame()); |
| 3497 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 3496 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 3498 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 3497 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |
| 3499 } | 3498 } |
| 3500 | 3499 |
| 3501 } // namespace | 3500 } // namespace |
| 3502 } // namespace cc | 3501 } // namespace cc |
| OLD | NEW |