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

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

Issue 1425973003: cc: Don't attempt main thread synchronization if it is slow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on 1415763008; existing tests pass; new tests needed Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 client_->Reset(); 478 client_->Reset();
479 EXPECT_SCOPED(AdvanceFrame()); 479 EXPECT_SCOPED(AdvanceFrame());
480 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); 480 EXPECT_TRUE(client_->begin_frame_is_sent_to_children());
481 } 481 }
482 482
483 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { 483 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) {
484 // Set up client with specified estimates. 484 // Set up client with specified estimates.
485 scheduler_settings_.use_external_begin_frame_source = true; 485 scheduler_settings_.use_external_begin_frame_source = true;
486 SetUpScheduler(true); 486 SetUpScheduler(true);
487 487
488 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 488 fake_compositor_timing_history_
489 base::TimeDelta::FromMilliseconds(2)); 489 ->SetBeginMainFrameStartToCommitDurationEstimate(
490 base::TimeDelta::FromMilliseconds(2));
490 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate( 491 fake_compositor_timing_history_->SetCommitToReadyToActivateDurationEstimate(
491 base::TimeDelta::FromMilliseconds(4)); 492 base::TimeDelta::FromMilliseconds(4));
492 fake_compositor_timing_history_->SetDrawDurationEstimate( 493 fake_compositor_timing_history_->SetDrawDurationEstimate(
493 base::TimeDelta::FromMilliseconds(1)); 494 base::TimeDelta::FromMilliseconds(1));
494 495
495 EXPECT_FALSE(client_->needs_begin_frames()); 496 EXPECT_FALSE(client_->needs_begin_frames());
496 scheduler_->SetChildrenNeedBeginFrames(true); 497 scheduler_->SetChildrenNeedBeginFrames(true);
497 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 498 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
498 EXPECT_TRUE(client_->needs_begin_frames()); 499 EXPECT_TRUE(client_->needs_begin_frames());
499 500
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 1395
1395 bool expect_send_begin_main_frame = false; 1396 bool expect_send_begin_main_frame = false;
1396 EXPECT_SCOPED( 1397 EXPECT_SCOPED(
1397 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1398 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1398 } 1399 }
1399 1400
1400 TEST_F(SchedulerTest, 1401 TEST_F(SchedulerTest,
1401 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) { 1402 MainFrameNotSkippedAfterLateCommitInPreferImplLatencyMode) {
1402 scheduler_settings_.use_external_begin_frame_source = true; 1403 scheduler_settings_.use_external_begin_frame_source = true;
1403 SetUpScheduler(true); 1404 SetUpScheduler(true);
1404 scheduler_->SetImplLatencyTakesPriority(true); 1405 scheduler_->SetSmoothnessMode(true, false);
1405 1406
1406 auto fast_duration = base::TimeDelta::FromMilliseconds(1); 1407 auto fast_duration = base::TimeDelta::FromMilliseconds(1);
1407 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); 1408 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration);
1408 1409
1409 bool expect_send_begin_main_frame = true; 1410 bool expect_send_begin_main_frame = true;
1410 EXPECT_SCOPED( 1411 EXPECT_SCOPED(
1411 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1412 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1412 } 1413 }
1413 1414
1414 TEST_F(SchedulerTest, 1415 TEST_F(SchedulerTest,
1415 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) { 1416 MainFrameNotSkippedAfterLateCommit_CommitEstimateTooLong) {
1416 scheduler_settings_.use_external_begin_frame_source = true; 1417 scheduler_settings_.use_external_begin_frame_source = true;
1417 SetUpScheduler(true); 1418 SetUpScheduler(true);
1418 auto fast_duration = base::TimeDelta::FromMilliseconds(1); 1419 auto fast_duration = base::TimeDelta::FromMilliseconds(1);
1419 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); 1420 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration);
1420 auto slow_duration = base::TimeDelta::FromSeconds(1); 1421 auto slow_duration = base::TimeDelta::FromSeconds(1);
1421 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1422 fake_compositor_timing_history_
1422 slow_duration); 1423 ->SetBeginMainFrameStartToCommitDurationEstimate(slow_duration);
1423 1424
1424 bool expect_send_begin_main_frame = true; 1425 bool expect_send_begin_main_frame = true;
1425 EXPECT_SCOPED( 1426 EXPECT_SCOPED(
1426 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame)); 1427 CheckMainFrameSkippedAfterLateCommit(expect_send_begin_main_frame));
1427 } 1428 }
1428 1429
1429 TEST_F(SchedulerTest, 1430 TEST_F(SchedulerTest,
1430 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) { 1431 MainFrameNotSkippedAfterLateCommit_ReadyToActivateEstimateTooLong) {
1431 scheduler_settings_.use_external_begin_frame_source = true; 1432 scheduler_settings_.use_external_begin_frame_source = true;
1432 SetUpScheduler(true); 1433 SetUpScheduler(true);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 } 1572 }
1572 1573
1573 TEST_F(SchedulerTest, 1574 TEST_F(SchedulerTest,
1574 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) { 1575 ImplFrameSkippedAfterLateSwapAck_ImplLatencyTakesPriority) {
1575 scheduler_settings_.use_external_begin_frame_source = true; 1576 scheduler_settings_.use_external_begin_frame_source = true;
1576 SetUpScheduler(true); 1577 SetUpScheduler(true);
1577 1578
1578 // Even if every estimate related to the main thread is slow, we should 1579 // Even if every estimate related to the main thread is slow, we should
1579 // still expect to recover impl thread latency if the draw is fast and we 1580 // still expect to recover impl thread latency if the draw is fast and we
1580 // are in impl latency takes priority. 1581 // are in impl latency takes priority.
1581 scheduler_->SetImplLatencyTakesPriority(true); 1582 scheduler_->SetSmoothnessMode(true, false);
1582 auto slow_duration = base::TimeDelta::FromSeconds(1); 1583 auto slow_duration = base::TimeDelta::FromSeconds(1);
1583 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration); 1584 fake_compositor_timing_history_->SetAllEstimatesTo(slow_duration);
1584 auto fast_duration = base::TimeDelta::FromMilliseconds(1); 1585 auto fast_duration = base::TimeDelta::FromMilliseconds(1);
1585 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration); 1586 fake_compositor_timing_history_->SetDrawDurationEstimate(fast_duration);
1586 1587
1587 bool swap_ack_before_deadline = false; 1588 bool swap_ack_before_deadline = false;
1588 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline)); 1589 EXPECT_SCOPED(ImplFrameSkippedAfterLateSwapAck(swap_ack_before_deadline));
1589 } 1590 }
1590 1591
1591 TEST_F(SchedulerTest, 1592 TEST_F(SchedulerTest,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 } 1712 }
1712 } 1713 }
1713 1714
1714 TEST_F(SchedulerTest, 1715 TEST_F(SchedulerTest,
1715 ImplFrameIsNotSkippedAfterLateSwapAck_CommitEstimateTooLong) { 1716 ImplFrameIsNotSkippedAfterLateSwapAck_CommitEstimateTooLong) {
1716 scheduler_settings_.use_external_begin_frame_source = true; 1717 scheduler_settings_.use_external_begin_frame_source = true;
1717 SetUpScheduler(true); 1718 SetUpScheduler(true);
1718 auto fast_duration = base::TimeDelta::FromMilliseconds(1); 1719 auto fast_duration = base::TimeDelta::FromMilliseconds(1);
1719 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); 1720 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration);
1720 auto slow_duration = base::TimeDelta::FromSeconds(1); 1721 auto slow_duration = base::TimeDelta::FromSeconds(1);
1721 fake_compositor_timing_history_->SetBeginMainFrameToCommitDurationEstimate( 1722 fake_compositor_timing_history_
1722 slow_duration); 1723 ->SetBeginMainFrameStartToCommitDurationEstimate(slow_duration);
1723 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck()); 1724 EXPECT_SCOPED(ImplFrameIsNotSkippedAfterLateSwapAck());
1724 } 1725 }
1725 1726
1726 TEST_F(SchedulerTest, 1727 TEST_F(SchedulerTest,
1727 ImplFrameIsNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) { 1728 ImplFrameIsNotSkippedAfterLateSwapAck_ReadyToActivateEstimateTooLong) {
1728 scheduler_settings_.use_external_begin_frame_source = true; 1729 scheduler_settings_.use_external_begin_frame_source = true;
1729 SetUpScheduler(true); 1730 SetUpScheduler(true);
1730 auto fast_duration = base::TimeDelta::FromMilliseconds(1); 1731 auto fast_duration = base::TimeDelta::FromMilliseconds(1);
1731 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration); 1732 fake_compositor_timing_history_->SetAllEstimatesTo(fast_duration);
1732 auto slow_duration = base::TimeDelta::FromSeconds(1); 1733 auto slow_duration = base::TimeDelta::FromSeconds(1);
(...skipping 1746 matching lines...) Expand 10 before | Expand all | Expand 10 after
3479 EXPECT_SCOPED(AdvanceFrame()); 3480 EXPECT_SCOPED(AdvanceFrame());
3480 3481
3481 // At the next BeginFrame, authoritative interval is used instead of previous 3482 // At the next BeginFrame, authoritative interval is used instead of previous
3482 // interval. 3483 // interval.
3483 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); 3484 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval());
3484 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); 3485 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval());
3485 } 3486 }
3486 3487
3487 TEST_F(SchedulerTest, ImplLatencyTakesPriority) { 3488 TEST_F(SchedulerTest, ImplLatencyTakesPriority) {
3488 SetUpScheduler(true); 3489 SetUpScheduler(true);
3489 scheduler_->SetImplLatencyTakesPriority(true); 3490 scheduler_->SetSmoothnessMode(true, false);
3490 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority()); 3491 EXPECT_TRUE(scheduler_->ImplLatencyTakesPriority());
3491 3492
3492 scheduler_->SetImplLatencyTakesPriority(false); 3493 scheduler_->SetSmoothnessMode(false, false);
3493 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority()); 3494 EXPECT_FALSE(scheduler_->ImplLatencyTakesPriority());
3494 } 3495 }
3495 3496
3496 TEST_F(SchedulerTest, BeginMainFrameArgs_OnCriticalPath) { 3497 TEST_F(SchedulerTest, BeginMainFrameArgs_OnCriticalPath) {
3497 scheduler_settings_.use_external_begin_frame_source = true; 3498 scheduler_settings_.use_external_begin_frame_source = true;
3498 SetUpScheduler(true); 3499 SetUpScheduler(true);
3499 3500
3500 scheduler_->SetImplLatencyTakesPriority(false); 3501 scheduler_->SetSmoothnessMode(false, false);
3501 scheduler_->SetNeedsBeginMainFrame(); 3502 scheduler_->SetNeedsBeginMainFrame();
3502 3503
3503 client_->Reset(); 3504 client_->Reset();
3504 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); 3505 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid());
3505 EXPECT_SCOPED(AdvanceFrame()); 3506 EXPECT_SCOPED(AdvanceFrame());
3506 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); 3507 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid());
3507 EXPECT_TRUE(client_->last_begin_main_frame_args().on_critical_path); 3508 EXPECT_TRUE(client_->last_begin_main_frame_args().on_critical_path);
3508 } 3509 }
3509 3510
3510 TEST_F(SchedulerTest, BeginMainFrameArgs_NotOnCriticalPath) { 3511 TEST_F(SchedulerTest, BeginMainFrameArgs_NotOnCriticalPath) {
3511 scheduler_settings_.use_external_begin_frame_source = true; 3512 scheduler_settings_.use_external_begin_frame_source = true;
3512 SetUpScheduler(true); 3513 SetUpScheduler(true);
3513 3514
3514 scheduler_->SetImplLatencyTakesPriority(true); 3515 scheduler_->SetSmoothnessMode(true, false);
3515 scheduler_->SetNeedsBeginMainFrame(); 3516 scheduler_->SetNeedsBeginMainFrame();
3516 3517
3517 client_->Reset(); 3518 client_->Reset();
3518 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid()); 3519 EXPECT_FALSE(client_->last_begin_main_frame_args().IsValid());
3519 EXPECT_SCOPED(AdvanceFrame()); 3520 EXPECT_SCOPED(AdvanceFrame());
3520 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid()); 3521 EXPECT_TRUE(client_->last_begin_main_frame_args().IsValid());
3521 EXPECT_FALSE(client_->last_begin_main_frame_args().on_critical_path); 3522 EXPECT_FALSE(client_->last_begin_main_frame_args().on_critical_path);
3522 } 3523 }
3523 3524
3524 } // namespace 3525 } // namespace
3525 } // namespace cc 3526 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698