| 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" |
| 11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/numerics/safe_conversions.h" | 13 #include "base/numerics/safe_conversions.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
| 17 #include "cc/debug/rendering_stats_instrumentation.h" |
| 17 #include "cc/test/begin_frame_args_test.h" | 18 #include "cc/test/begin_frame_args_test.h" |
| 18 #include "cc/test/ordered_simple_task_runner.h" | 19 #include "cc/test/ordered_simple_task_runner.h" |
| 19 #include "cc/test/scheduler_test_common.h" | 20 #include "cc/test/scheduler_test_common.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 23 |
| 23 #define EXPECT_ACTION(action, client, action_index, expected_num_actions) \ | 24 #define EXPECT_ACTION(action, client, action_index, expected_num_actions) \ |
| 24 do { \ | 25 do { \ |
| 25 EXPECT_EQ(expected_num_actions, client->num_actions_()); \ | 26 EXPECT_EQ(expected_num_actions, client->num_actions_()); \ |
| 26 if (action_index >= 0) { \ | 27 if (action_index >= 0) { \ |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 void ScheduledActionBeginOutputSurfaceCreation() override { | 135 void ScheduledActionBeginOutputSurfaceCreation() override { |
| 135 PushAction("ScheduledActionBeginOutputSurfaceCreation"); | 136 PushAction("ScheduledActionBeginOutputSurfaceCreation"); |
| 136 } | 137 } |
| 137 void ScheduledActionPrepareTiles() override { | 138 void ScheduledActionPrepareTiles() override { |
| 138 PushAction("ScheduledActionPrepareTiles"); | 139 PushAction("ScheduledActionPrepareTiles"); |
| 139 } | 140 } |
| 140 void ScheduledActionInvalidateOutputSurface() override { | 141 void ScheduledActionInvalidateOutputSurface() override { |
| 141 actions_.push_back("ScheduledActionInvalidateOutputSurface"); | 142 actions_.push_back("ScheduledActionInvalidateOutputSurface"); |
| 142 states_.push_back(scheduler_->AsValue()); | 143 states_.push_back(scheduler_->AsValue()); |
| 143 } | 144 } |
| 144 base::TimeDelta DrawDurationEstimate() override { return base::TimeDelta(); } | |
| 145 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override { | |
| 146 return base::TimeDelta(); | |
| 147 } | |
| 148 base::TimeDelta CommitToActivateDurationEstimate() override { | |
| 149 return base::TimeDelta(); | |
| 150 } | |
| 151 | 145 |
| 152 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { | 146 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
| 153 begin_frame_args_sent_to_children_ = args; | 147 begin_frame_args_sent_to_children_ = args; |
| 154 } | 148 } |
| 155 | 149 |
| 156 void SendBeginMainFrameNotExpectedSoon() override { | 150 void SendBeginMainFrameNotExpectedSoon() override { |
| 157 PushAction("SendBeginMainFrameNotExpectedSoon"); | 151 PushAction("SendBeginMainFrameNotExpectedSoon"); |
| 158 } | 152 } |
| 159 | 153 |
| 160 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { | 154 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 186 bool automatic_swap_ack_; | 180 bool automatic_swap_ack_; |
| 187 int num_draws_; | 181 int num_draws_; |
| 188 BeginFrameArgs begin_frame_args_sent_to_children_; | 182 BeginFrameArgs begin_frame_args_sent_to_children_; |
| 189 base::TimeTicks posted_begin_impl_frame_deadline_; | 183 base::TimeTicks posted_begin_impl_frame_deadline_; |
| 190 std::vector<const char*> actions_; | 184 std::vector<const char*> actions_; |
| 191 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>> | 185 std::vector<scoped_refptr<base::trace_event::ConvertableToTraceFormat>> |
| 192 states_; | 186 states_; |
| 193 TestScheduler* scheduler_; | 187 TestScheduler* scheduler_; |
| 194 }; | 188 }; |
| 195 | 189 |
| 196 class SchedulerClientWithFixedEstimates : public FakeSchedulerClient { | |
| 197 public: | |
| 198 SchedulerClientWithFixedEstimates( | |
| 199 base::TimeDelta draw_duration, | |
| 200 base::TimeDelta begin_main_frame_to_commit_duration, | |
| 201 base::TimeDelta commit_to_activate_duration) | |
| 202 : draw_duration_(draw_duration), | |
| 203 begin_main_frame_to_commit_duration_( | |
| 204 begin_main_frame_to_commit_duration), | |
| 205 commit_to_activate_duration_(commit_to_activate_duration) {} | |
| 206 | |
| 207 base::TimeDelta DrawDurationEstimate() override { return draw_duration_; } | |
| 208 base::TimeDelta BeginMainFrameToCommitDurationEstimate() override { | |
| 209 return begin_main_frame_to_commit_duration_; | |
| 210 } | |
| 211 base::TimeDelta CommitToActivateDurationEstimate() override { | |
| 212 return commit_to_activate_duration_; | |
| 213 } | |
| 214 | |
| 215 private: | |
| 216 base::TimeDelta draw_duration_; | |
| 217 base::TimeDelta begin_main_frame_to_commit_duration_; | |
| 218 base::TimeDelta commit_to_activate_duration_; | |
| 219 }; | |
| 220 | |
| 221 class FakeExternalBeginFrameSource : public BeginFrameSourceBase { | 190 class FakeExternalBeginFrameSource : public BeginFrameSourceBase { |
| 222 public: | 191 public: |
| 223 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) | 192 explicit FakeExternalBeginFrameSource(FakeSchedulerClient* client) |
| 224 : client_(client) {} | 193 : client_(client) {} |
| 225 ~FakeExternalBeginFrameSource() override {} | 194 ~FakeExternalBeginFrameSource() override {} |
| 226 | 195 |
| 227 void OnNeedsBeginFramesChange(bool needs_begin_frames) override { | 196 void OnNeedsBeginFramesChange(bool needs_begin_frames) override { |
| 228 if (needs_begin_frames) { | 197 if (needs_begin_frames) { |
| 229 client_->PushAction("SetNeedsBeginFrames(true)"); | 198 client_->PushAction("SetNeedsBeginFrames(true)"); |
| 230 } else { | 199 } else { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 258 | 227 |
| 259 protected: | 228 protected: |
| 260 TestScheduler* CreateScheduler() { | 229 TestScheduler* CreateScheduler() { |
| 261 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; | 230 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; |
| 262 if (scheduler_settings_.use_external_begin_frame_source) { | 231 if (scheduler_settings_.use_external_begin_frame_source) { |
| 263 fake_external_begin_frame_source.reset( | 232 fake_external_begin_frame_source.reset( |
| 264 new FakeExternalBeginFrameSource(client_.get())); | 233 new FakeExternalBeginFrameSource(client_.get())); |
| 265 fake_external_begin_frame_source_ = | 234 fake_external_begin_frame_source_ = |
| 266 fake_external_begin_frame_source.get(); | 235 fake_external_begin_frame_source.get(); |
| 267 } | 236 } |
| 237 rendering_stats_instrumentation_ = RenderingStatsInstrumentation::Create(); |
| 268 scheduler_ = TestScheduler::Create(now_src_.get(), client_.get(), | 238 scheduler_ = TestScheduler::Create(now_src_.get(), client_.get(), |
| 269 scheduler_settings_, 0, task_runner_, | 239 scheduler_settings_, 0, task_runner_, |
| 270 fake_external_begin_frame_source.Pass()); | 240 fake_external_begin_frame_source.Pass(), |
| 241 rendering_stats_instrumentation_.get()); |
| 271 DCHECK(scheduler_); | 242 DCHECK(scheduler_); |
| 272 client_->set_scheduler(scheduler_.get()); | 243 client_->set_scheduler(scheduler_.get()); |
| 273 return scheduler_.get(); | 244 return scheduler_.get(); |
| 274 } | 245 } |
| 275 | 246 |
| 276 void CreateSchedulerAndInitSurface() { | 247 void CreateSchedulerAndInitSurface() { |
| 277 CreateScheduler(); | 248 CreateScheduler(); |
| 278 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); | 249 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); |
| 279 } | 250 } |
| 280 | 251 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 void BeginFramesNotFromClient_SwapThrottled( | 389 void BeginFramesNotFromClient_SwapThrottled( |
| 419 bool use_external_begin_frame_source, | 390 bool use_external_begin_frame_source, |
| 420 bool throttle_frame_production); | 391 bool throttle_frame_production); |
| 421 | 392 |
| 422 scoped_ptr<base::SimpleTestTickClock> now_src_; | 393 scoped_ptr<base::SimpleTestTickClock> now_src_; |
| 423 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 394 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
| 424 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; | 395 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; |
| 425 SchedulerSettings scheduler_settings_; | 396 SchedulerSettings scheduler_settings_; |
| 426 scoped_ptr<FakeSchedulerClient> client_; | 397 scoped_ptr<FakeSchedulerClient> client_; |
| 427 scoped_ptr<TestScheduler> scheduler_; | 398 scoped_ptr<TestScheduler> scheduler_; |
| 399 scoped_ptr<RenderingStatsInstrumentation> rendering_stats_instrumentation_; |
| 428 }; | 400 }; |
| 429 | 401 |
| 430 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { | 402 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { |
| 431 scheduler_settings_.use_external_begin_frame_source = true; | 403 scheduler_settings_.use_external_begin_frame_source = true; |
| 432 SetUpScheduler(false); | 404 SetUpScheduler(false); |
| 433 scheduler_->SetCanStart(); | 405 scheduler_->SetCanStart(); |
| 434 scheduler_->SetVisible(true); | 406 scheduler_->SetVisible(true); |
| 435 scheduler_->SetCanDraw(true); | 407 scheduler_->SetCanDraw(true); |
| 436 | 408 |
| 437 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); | 409 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 441 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 470 EXPECT_TRUE(client_->needs_begin_frames()); | 442 EXPECT_TRUE(client_->needs_begin_frames()); |
| 471 | 443 |
| 472 client_->Reset(); | 444 client_->Reset(); |
| 473 EXPECT_SCOPED(AdvanceFrame()); | 445 EXPECT_SCOPED(AdvanceFrame()); |
| 474 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 446 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 475 } | 447 } |
| 476 | 448 |
| 477 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { | 449 TEST_F(SchedulerTest, SendBeginFramesToChildrenDeadlineNotAdjusted) { |
| 478 // Set up client with specified estimates. | 450 // Set up client with specified estimates. |
| 479 SchedulerClientWithFixedEstimates* client = | |
| 480 new SchedulerClientWithFixedEstimates( | |
| 481 base::TimeDelta::FromMilliseconds(1), | |
| 482 base::TimeDelta::FromMilliseconds(2), | |
| 483 base::TimeDelta::FromMilliseconds(4)); | |
| 484 scheduler_settings_.use_external_begin_frame_source = true; | 451 scheduler_settings_.use_external_begin_frame_source = true; |
| 485 SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 452 SetUpScheduler(true); |
| 453 scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1)); |
| 454 scheduler_->SetBeginMainFrameToCommitDurationEstimate( |
| 455 base::TimeDelta::FromMilliseconds(2)); |
| 456 scheduler_->SetCommitToActivateDurationEstimate( |
| 457 base::TimeDelta::FromMilliseconds(4)); |
| 486 | 458 |
| 487 EXPECT_FALSE(client_->needs_begin_frames()); | 459 EXPECT_FALSE(client_->needs_begin_frames()); |
| 488 scheduler_->SetChildrenNeedBeginFrames(true); | 460 scheduler_->SetChildrenNeedBeginFrames(true); |
| 489 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 461 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
| 490 EXPECT_TRUE(client_->needs_begin_frames()); | 462 EXPECT_TRUE(client_->needs_begin_frames()); |
| 491 | 463 |
| 492 client_->Reset(); | 464 client_->Reset(); |
| 493 | 465 |
| 494 BeginFrameArgs frame_args = | 466 BeginFrameArgs frame_args = |
| 495 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 467 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); | 1286 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); |
| 1315 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); | 1287 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); |
| 1316 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); | 1288 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3); |
| 1317 } | 1289 } |
| 1318 | 1290 |
| 1319 void SchedulerTest::MainFrameInHighLatencyMode( | 1291 void SchedulerTest::MainFrameInHighLatencyMode( |
| 1320 int64 begin_main_frame_to_commit_estimate_in_ms, | 1292 int64 begin_main_frame_to_commit_estimate_in_ms, |
| 1321 int64 commit_to_activate_estimate_in_ms, | 1293 int64 commit_to_activate_estimate_in_ms, |
| 1322 bool impl_latency_takes_priority, | 1294 bool impl_latency_takes_priority, |
| 1323 bool should_send_begin_main_frame) { | 1295 bool should_send_begin_main_frame) { |
| 1324 // Set up client with specified estimates (draw duration is set to 1). | 1296 scheduler_settings_.use_external_begin_frame_source = true; |
| 1325 SchedulerClientWithFixedEstimates* client = | 1297 SetUpScheduler(true); |
| 1326 new SchedulerClientWithFixedEstimates( | |
| 1327 base::TimeDelta::FromMilliseconds(1), | |
| 1328 base::TimeDelta::FromMilliseconds( | |
| 1329 begin_main_frame_to_commit_estimate_in_ms), | |
| 1330 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); | |
| 1331 | 1298 |
| 1332 scheduler_settings_.use_external_begin_frame_source = true; | 1299 scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1)); |
| 1333 SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 1300 scheduler_->SetBeginMainFrameToCommitDurationEstimate( |
| 1301 base::TimeDelta::FromMilliseconds( |
| 1302 begin_main_frame_to_commit_estimate_in_ms)); |
| 1303 scheduler_->SetCommitToActivateDurationEstimate( |
| 1304 base::TimeDelta::FromMilliseconds(commit_to_activate_estimate_in_ms)); |
| 1334 | 1305 |
| 1335 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); | 1306 scheduler_->SetImplLatencyTakesPriority(impl_latency_takes_priority); |
| 1336 | 1307 |
| 1337 // Impl thread hits deadline before commit finishes. | 1308 // Impl thread hits deadline before commit finishes. |
| 1338 scheduler_->SetNeedsCommit(); | 1309 scheduler_->SetNeedsCommit(); |
| 1339 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1310 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1340 EXPECT_SCOPED(AdvanceFrame()); | 1311 EXPECT_SCOPED(AdvanceFrame()); |
| 1341 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); | 1312 EXPECT_FALSE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1342 task_runner().RunPendingTasks(); // Run posted deadline. | 1313 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1343 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1314 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1344 scheduler_->NotifyBeginMainFrameStarted(); | 1315 scheduler_->NotifyBeginMainFrameStarted(); |
| 1345 scheduler_->NotifyReadyToCommit(); | 1316 scheduler_->NotifyReadyToCommit(); |
| 1346 scheduler_->NotifyReadyToActivate(); | 1317 scheduler_->NotifyReadyToActivate(); |
| 1347 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1318 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1348 EXPECT_TRUE(client->HasAction("ScheduledActionSendBeginMainFrame")); | 1319 EXPECT_TRUE(client_->HasAction("ScheduledActionSendBeginMainFrame")); |
| 1349 | 1320 |
| 1350 client->Reset(); | 1321 client_->Reset(); |
| 1351 scheduler_->SetNeedsCommit(); | 1322 scheduler_->SetNeedsCommit(); |
| 1352 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1323 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1353 EXPECT_SCOPED(AdvanceFrame()); | 1324 EXPECT_SCOPED(AdvanceFrame()); |
| 1354 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); | 1325 EXPECT_TRUE(scheduler_->MainThreadIsInHighLatencyMode()); |
| 1355 task_runner().RunPendingTasks(); // Run posted deadline. | 1326 task_runner().RunPendingTasks(); // Run posted deadline. |
| 1356 EXPECT_EQ(scheduler_->MainThreadIsInHighLatencyMode(), | 1327 EXPECT_EQ(scheduler_->MainThreadIsInHighLatencyMode(), |
| 1357 should_send_begin_main_frame); | 1328 should_send_begin_main_frame); |
| 1358 EXPECT_EQ(client->HasAction("ScheduledActionSendBeginMainFrame"), | 1329 EXPECT_EQ(client_->HasAction("ScheduledActionSendBeginMainFrame"), |
| 1359 should_send_begin_main_frame); | 1330 should_send_begin_main_frame); |
| 1360 } | 1331 } |
| 1361 | 1332 |
| 1362 TEST_F(SchedulerTest, | 1333 TEST_F(SchedulerTest, |
| 1363 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) { | 1334 SkipMainFrameIfHighLatencyAndCanCommitAndActivateBeforeDeadline) { |
| 1364 // Set up client so that estimates indicate that we can commit and activate | 1335 // Set up client so that estimates indicate that we can commit and activate |
| 1365 // before the deadline (~8ms by default). | 1336 // before the deadline (~8ms by default). |
| 1366 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 1, false, false)); | 1337 EXPECT_SCOPED(MainFrameInHighLatencyMode(1, 1, false, false)); |
| 1367 } | 1338 } |
| 1368 | 1339 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1386 } | 1357 } |
| 1387 | 1358 |
| 1388 TEST_F( | 1359 TEST_F( |
| 1389 SchedulerTest, | 1360 SchedulerTest, |
| 1390 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { | 1361 Deadlock_CommitMakesProgressWhileSwapTrottledAndActiveTreeNeedsFirstDraw) { |
| 1391 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main | 1362 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main |
| 1392 // thread. This prevents the scheduler from receiving any pending swap acks. | 1363 // thread. This prevents the scheduler from receiving any pending swap acks. |
| 1393 | 1364 |
| 1394 // Since we are simulating a long commit, set up a client with draw duration | 1365 // Since we are simulating a long commit, set up a client with draw duration |
| 1395 // estimates that prevent skipping main frames to get to low latency mode. | 1366 // estimates that prevent skipping main frames to get to low latency mode. |
| 1396 SchedulerClientWithFixedEstimates* client = | |
| 1397 new SchedulerClientWithFixedEstimates( | |
| 1398 base::TimeDelta::FromMilliseconds(1), | |
| 1399 base::TimeDelta::FromMilliseconds(32), | |
| 1400 base::TimeDelta::FromMilliseconds(32)); | |
| 1401 scheduler_settings_.use_external_begin_frame_source = true; | 1367 scheduler_settings_.use_external_begin_frame_source = true; |
| 1402 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1368 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1403 SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 1369 SetUpScheduler(true); |
| 1370 |
| 1371 scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1)); |
| 1372 scheduler_->SetBeginMainFrameToCommitDurationEstimate( |
| 1373 base::TimeDelta::FromMilliseconds(32)); |
| 1374 scheduler_->SetCommitToActivateDurationEstimate( |
| 1375 base::TimeDelta::FromMilliseconds(32)); |
| 1404 | 1376 |
| 1405 // Disables automatic swap acks so this test can force swap ack throttling | 1377 // Disables automatic swap acks so this test can force swap ack throttling |
| 1406 // to simulate a blocked Browser ui thread. | 1378 // to simulate a blocked Browser ui thread. |
| 1407 scheduler_->SetMaxSwapsPending(1); | 1379 scheduler_->SetMaxSwapsPending(1); |
| 1408 client_->SetAutomaticSwapAck(false); | 1380 client_->SetAutomaticSwapAck(false); |
| 1409 | 1381 |
| 1410 // Get a new active tree in main-thread high latency mode and put us | 1382 // Get a new active tree in main-thread high latency mode and put us |
| 1411 // in a swap throttled state. | 1383 // in a swap throttled state. |
| 1412 client_->Reset(); | 1384 client_->Reset(); |
| 1413 EXPECT_FALSE(scheduler_->CommitPending()); | 1385 EXPECT_FALSE(scheduler_->CommitPending()); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1463 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) { | 1435 Deadlock_NoBeginMainFrameWhileSwapTrottledAndPipelineFull) { |
| 1464 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main | 1436 // NPAPI plugins on Windows block the Browser UI thread on the Renderer main |
| 1465 // thread. This prevents the scheduler from receiving any pending swap acks. | 1437 // thread. This prevents the scheduler from receiving any pending swap acks. |
| 1466 | 1438 |
| 1467 // This particular test makes sure we do not send a BeginMainFrame while | 1439 // This particular test makes sure we do not send a BeginMainFrame while |
| 1468 // swap trottled and we have a pending tree and active tree that | 1440 // swap trottled and we have a pending tree and active tree that |
| 1469 // still needs to be drawn for the first time. | 1441 // still needs to be drawn for the first time. |
| 1470 | 1442 |
| 1471 // Since we are simulating a long commit, set up a client with draw duration | 1443 // Since we are simulating a long commit, set up a client with draw duration |
| 1472 // estimates that prevent skipping main frames to get to low latency mode. | 1444 // estimates that prevent skipping main frames to get to low latency mode. |
| 1473 SchedulerClientWithFixedEstimates* client = | |
| 1474 new SchedulerClientWithFixedEstimates( | |
| 1475 base::TimeDelta::FromMilliseconds(1), | |
| 1476 base::TimeDelta::FromMilliseconds(32), | |
| 1477 base::TimeDelta::FromMilliseconds(32)); | |
| 1478 scheduler_settings_.use_external_begin_frame_source = true; | 1445 scheduler_settings_.use_external_begin_frame_source = true; |
| 1479 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1446 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1480 scheduler_settings_.main_frame_before_activation_enabled = true; | 1447 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1481 SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 1448 SetUpScheduler(true); |
| 1449 |
| 1450 scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1)); |
| 1451 scheduler_->SetBeginMainFrameToCommitDurationEstimate( |
| 1452 base::TimeDelta::FromMilliseconds(32)); |
| 1453 scheduler_->SetCommitToActivateDurationEstimate( |
| 1454 base::TimeDelta::FromMilliseconds(32)); |
| 1482 | 1455 |
| 1483 // Disables automatic swap acks so this test can force swap ack throttling | 1456 // Disables automatic swap acks so this test can force swap ack throttling |
| 1484 // to simulate a blocked Browser ui thread. | 1457 // to simulate a blocked Browser ui thread. |
| 1485 scheduler_->SetMaxSwapsPending(1); | 1458 scheduler_->SetMaxSwapsPending(1); |
| 1486 client_->SetAutomaticSwapAck(false); | 1459 client_->SetAutomaticSwapAck(false); |
| 1487 | 1460 |
| 1488 // Start a new commit in main-thread high latency mode and hold off on | 1461 // Start a new commit in main-thread high latency mode and hold off on |
| 1489 // activation. | 1462 // activation. |
| 1490 client_->Reset(); | 1463 client_->Reset(); |
| 1491 EXPECT_FALSE(scheduler_->CommitPending()); | 1464 EXPECT_FALSE(scheduler_->CommitPending()); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 } | 1522 } |
| 1550 | 1523 |
| 1551 TEST_F( | 1524 TEST_F( |
| 1552 SchedulerTest, | 1525 SchedulerTest, |
| 1553 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { | 1526 CommitMakesProgressWhenIdleAndHasPendingTreeAndActiveTreeNeedsFirstDraw) { |
| 1554 // This verifies we don't block commits longer than we need to | 1527 // This verifies we don't block commits longer than we need to |
| 1555 // for performance reasons - not deadlock reasons. | 1528 // for performance reasons - not deadlock reasons. |
| 1556 | 1529 |
| 1557 // Since we are simulating a long commit, set up a client with draw duration | 1530 // Since we are simulating a long commit, set up a client with draw duration |
| 1558 // estimates that prevent skipping main frames to get to low latency mode. | 1531 // estimates that prevent skipping main frames to get to low latency mode. |
| 1559 SchedulerClientWithFixedEstimates* client = | |
| 1560 new SchedulerClientWithFixedEstimates( | |
| 1561 base::TimeDelta::FromMilliseconds(1), | |
| 1562 base::TimeDelta::FromMilliseconds(32), | |
| 1563 base::TimeDelta::FromMilliseconds(32)); | |
| 1564 scheduler_settings_.use_external_begin_frame_source = true; | 1532 scheduler_settings_.use_external_begin_frame_source = true; |
| 1565 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; | 1533 scheduler_settings_.main_frame_while_swap_throttled_enabled = true; |
| 1566 scheduler_settings_.main_frame_before_activation_enabled = true; | 1534 scheduler_settings_.main_frame_before_activation_enabled = true; |
| 1567 SetUpScheduler(make_scoped_ptr(client).Pass(), true); | 1535 SetUpScheduler(true); |
| 1536 |
| 1537 scheduler_->SetDrawDurationEstimate(base::TimeDelta::FromMilliseconds(1)); |
| 1538 scheduler_->SetBeginMainFrameToCommitDurationEstimate( |
| 1539 base::TimeDelta::FromMilliseconds(32)); |
| 1540 scheduler_->SetCommitToActivateDurationEstimate( |
| 1541 base::TimeDelta::FromMilliseconds(32)); |
| 1568 | 1542 |
| 1569 // Disables automatic swap acks so this test can force swap ack throttling | 1543 // Disables automatic swap acks so this test can force swap ack throttling |
| 1570 // to simulate a blocked Browser ui thread. | 1544 // to simulate a blocked Browser ui thread. |
| 1571 scheduler_->SetMaxSwapsPending(1); | 1545 scheduler_->SetMaxSwapsPending(1); |
| 1572 client_->SetAutomaticSwapAck(false); | 1546 client_->SetAutomaticSwapAck(false); |
| 1573 | 1547 |
| 1574 // Start a new commit in main-thread high latency mode and hold off on | 1548 // Start a new commit in main-thread high latency mode and hold off on |
| 1575 // activation. | 1549 // activation. |
| 1576 client_->Reset(); | 1550 client_->Reset(); |
| 1577 EXPECT_FALSE(scheduler_->CommitPending()); | 1551 EXPECT_FALSE(scheduler_->CommitPending()); |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2981 scheduler_->SetImplLatencyTakesPriority(true); | 2955 scheduler_->SetImplLatencyTakesPriority(true); |
| 2982 scheduler_->SetChildrenNeedBeginFrames(true); | 2956 scheduler_->SetChildrenNeedBeginFrames(true); |
| 2983 | 2957 |
| 2984 EXPECT_SCOPED(AdvanceFrame()); | 2958 EXPECT_SCOPED(AdvanceFrame()); |
| 2985 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); | 2959 EXPECT_TRUE(client_->begin_frame_is_sent_to_children()); |
| 2986 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); | 2960 EXPECT_FALSE(client_->begin_frame_args_sent_to_children().on_critical_path); |
| 2987 } | 2961 } |
| 2988 | 2962 |
| 2989 } // namespace | 2963 } // namespace |
| 2990 } // namespace cc | 2964 } // namespace cc |
| OLD | NEW |