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

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

Issue 2632563003: [cc] Calculate the correct latest_confirmed_sequence_number in cc::Scheduler. (Closed)
Patch Set: Created 3 years, 11 months 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 BeginFrameArgs adjusted_args = args; 315 BeginFrameArgs adjusted_args = args;
316 // Cancel the missed begin frame task in case the BFS sends a begin frame 316 // Cancel the missed begin frame task in case the BFS sends a begin frame
317 // before the missed frame task runs. 317 // before the missed frame task runs.
318 missed_begin_frame_task_.Cancel(); 318 missed_begin_frame_task_.Cancel();
319 319
320 base::TimeTicks now = Now(); 320 base::TimeTicks now = Now();
321 321
322 // Discard missed begin frames if they are too late. 322 // Discard missed begin frames if they are too late.
323 if (adjusted_args.type == BeginFrameArgs::MISSED && 323 if (adjusted_args.type == BeginFrameArgs::MISSED &&
324 now > adjusted_args.deadline) { 324 now > adjusted_args.deadline) {
325 // TODO(eseckler): Determine and set correct |ack.latest_confirmed_frame|. 325 BeginFrameAck ack(
326 BeginFrameAck ack(adjusted_args.source_id, adjusted_args.sequence_number, 326 adjusted_args.source_id, adjusted_args.sequence_number,
327 adjusted_args.sequence_number, 0, false); 327 state_machine_.last_frame_number_compositor_frame_was_fresh(), 0,
328 false);
328 begin_frame_source_->DidFinishFrame(this, ack); 329 begin_frame_source_->DidFinishFrame(this, ack);
329 return; 330 return;
330 } 331 }
331 332
332 // Run the previous deadline if any. 333 // Run the previous deadline if any.
333 if (state_machine_.begin_impl_frame_state() == 334 if (state_machine_.begin_impl_frame_state() ==
334 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) { 335 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) {
335 OnBeginImplFrameDeadline(); 336 OnBeginImplFrameDeadline();
336 // We may not need begin frames any longer. 337 // We may not need begin frames any longer.
337 if (!observing_begin_frame_source_) { 338 if (!observing_begin_frame_source_) {
338 // TODO(eseckler): Determine and set correct |ack.latest_confirmed_frame|. 339 BeginFrameAck ack(
339 BeginFrameAck ack(adjusted_args.source_id, adjusted_args.sequence_number, 340 adjusted_args.source_id, adjusted_args.sequence_number,
340 adjusted_args.sequence_number, 0, false); 341 state_machine_.last_frame_number_compositor_frame_was_fresh(), 0,
342 false);
341 begin_frame_source_->DidFinishFrame(this, ack); 343 begin_frame_source_->DidFinishFrame(this, ack);
342 return; 344 return;
343 } 345 }
344 } 346 }
345 DCHECK_EQ(state_machine_.begin_impl_frame_state(), 347 DCHECK_EQ(state_machine_.begin_impl_frame_state(),
346 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 348 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
347 349
348 bool main_thread_is_in_high_latency_mode = 350 bool main_thread_is_in_high_latency_mode =
349 state_machine_.main_thread_missed_last_deadline(); 351 state_machine_.main_thread_missed_last_deadline();
350 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args", 352 TRACE_EVENT2("cc,benchmark", "Scheduler::BeginImplFrame", "args",
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 393
392 if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) { 394 if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) {
393 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", 395 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency",
394 TRACE_EVENT_SCOPE_THREAD); 396 TRACE_EVENT_SCOPE_THREAD);
395 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); 397 state_machine_.SetSkipNextBeginMainFrameToReduceLatency();
396 } else if (ShouldRecoverImplLatency(adjusted_args, 398 } else if (ShouldRecoverImplLatency(adjusted_args,
397 can_activate_before_deadline)) { 399 can_activate_before_deadline)) {
398 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency", 400 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency",
399 TRACE_EVENT_SCOPE_THREAD); 401 TRACE_EVENT_SCOPE_THREAD);
400 if (begin_frame_source_) { 402 if (begin_frame_source_) {
401 // TODO(eseckler): Determine and set correct |ack.latest_confirmed_frame|. 403 BeginFrameAck ack(
402 BeginFrameAck ack(adjusted_args.source_id, adjusted_args.sequence_number, 404 adjusted_args.source_id, adjusted_args.sequence_number,
403 adjusted_args.sequence_number, 0, false); 405 state_machine_.last_frame_number_compositor_frame_was_fresh(), 0,
406 false);
404 begin_frame_source_->DidFinishFrame(this, ack); 407 begin_frame_source_->DidFinishFrame(this, ack);
405 } 408 }
406 return; 409 return;
407 } 410 }
408 411
409 BeginImplFrame(adjusted_args); 412 BeginImplFrame(adjusted_args);
410 } 413 }
411 414
412 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) { 415 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) {
413 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args", 416 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args",
(...skipping 10 matching lines...) Expand all
424 state_machine_.needs_redraw()); 427 state_machine_.needs_redraw());
425 FinishImplFrame(); 428 FinishImplFrame();
426 } 429 }
427 430
428 void Scheduler::FinishImplFrame() { 431 void Scheduler::FinishImplFrame() {
429 state_machine_.OnBeginImplFrameIdle(); 432 state_machine_.OnBeginImplFrameIdle();
430 ProcessScheduledActions(); 433 ProcessScheduledActions();
431 434
432 client_->DidFinishImplFrame(); 435 client_->DidFinishImplFrame();
433 if (begin_frame_source_) { 436 if (begin_frame_source_) {
434 // TODO(eseckler): Determine and set correct |ack.latest_confirmed_frame|. 437 BeginFrameAck ack(
435 BeginFrameAck ack(begin_main_frame_args_.source_id, 438 begin_main_frame_args_.source_id,
brianderson 2017/01/13 19:13:49 The begin_main_frame_args_.source_id at this point
Sami 2017/01/16 10:41:02 I think this is okay, because when the source_id c
Eric Seckler 2017/01/16 14:33:01 What Sami said. :) Regarding telling the state mac
Eric Seckler 2017/01/17 18:01:24 Badum.. I'm just realizing that this is broken sin
436 begin_main_frame_args_.sequence_number, 439 begin_main_frame_args_.sequence_number,
437 begin_main_frame_args_.sequence_number, 0, 440 state_machine_.last_frame_number_compositor_frame_was_fresh(), 0,
438 state_machine_.did_submit_in_last_frame()); 441 state_machine_.did_submit_in_last_frame());
439 begin_frame_source_->DidFinishFrame(this, ack); 442 begin_frame_source_->DidFinishFrame(this, ack);
440 } 443 }
441 begin_impl_frame_tracker_.Finish(); 444 begin_impl_frame_tracker_.Finish();
442 } 445 }
443 446
444 // BeginImplFrame starts a compositor frame that will wait up until a deadline 447 // BeginImplFrame starts a compositor frame that will wait up until a deadline
445 // for a BeginMainFrame+activation to complete before it times out and draws 448 // for a BeginMainFrame+activation to complete before it times out and draws
446 // any asynchronous animation and scroll/pinch updates. 449 // any asynchronous animation and scroll/pinch updates.
447 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { 450 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
448 DCHECK_EQ(state_machine_.begin_impl_frame_state(), 451 DCHECK_EQ(state_machine_.begin_impl_frame_state(),
449 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); 452 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE);
450 DCHECK(begin_impl_frame_deadline_task_.IsCancelled()); 453 DCHECK(begin_impl_frame_deadline_task_.IsCancelled());
451 DCHECK(state_machine_.HasInitializedCompositorFrameSink()); 454 DCHECK(state_machine_.HasInitializedCompositorFrameSink());
452 455
453 begin_impl_frame_tracker_.Start(args); 456 begin_impl_frame_tracker_.Start(args);
454 state_machine_.OnBeginImplFrame(); 457 state_machine_.OnBeginImplFrame(args.source_id, args.sequence_number);
455 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_); 458 devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
456 compositor_timing_history_->WillBeginImplFrame( 459 compositor_timing_history_->WillBeginImplFrame(
457 state_machine_.NewActiveTreeLikely()); 460 state_machine_.NewActiveTreeLikely());
458 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current()); 461 client_->WillBeginImplFrame(begin_impl_frame_tracker_.Current());
459 462
460 ProcessScheduledActions(); 463 ProcessScheduledActions();
461 } 464 }
462 465
463 void Scheduler::ScheduleBeginImplFrameDeadline() { 466 void Scheduler::ScheduleBeginImplFrameDeadline() {
464 // The synchronous compositor does not post a deadline task. 467 // The synchronous compositor does not post a deadline task.
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 } 770 }
768 771
769 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 772 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
770 return (state_machine_.begin_main_frame_state() == 773 return (state_machine_.begin_main_frame_state() ==
771 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || 774 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT ||
772 state_machine_.begin_main_frame_state() == 775 state_machine_.begin_main_frame_state() ==
773 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); 776 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED);
774 } 777 }
775 778
776 } // namespace cc 779 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698