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

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

Issue 2819723002: cc: Add more info to the BeginMainFrame dump. (Closed)
Patch Set: more tracing Created 3 years, 8 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 19 matching lines...) Expand all
30 Scheduler::Scheduler( 30 Scheduler::Scheduler(
31 SchedulerClient* client, 31 SchedulerClient* client,
32 const SchedulerSettings& settings, 32 const SchedulerSettings& settings,
33 int layer_tree_host_id, 33 int layer_tree_host_id,
34 base::SingleThreadTaskRunner* task_runner, 34 base::SingleThreadTaskRunner* task_runner,
35 std::unique_ptr<CompositorTimingHistory> compositor_timing_history) 35 std::unique_ptr<CompositorTimingHistory> compositor_timing_history)
36 : settings_(settings), 36 : settings_(settings),
37 client_(client), 37 client_(client),
38 layer_tree_host_id_(layer_tree_host_id), 38 layer_tree_host_id_(layer_tree_host_id),
39 task_runner_(task_runner), 39 task_runner_(task_runner),
40 begin_frame_source_(nullptr),
41 observing_begin_frame_source_(false),
42 compositor_timing_history_(std::move(compositor_timing_history)), 40 compositor_timing_history_(std::move(compositor_timing_history)),
43 begin_impl_frame_deadline_mode_(
44 SchedulerStateMachine::BEGIN_IMPL_FRAME_DEADLINE_MODE_NONE),
45 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE), 41 begin_impl_frame_tracker_(BEGINFRAMETRACKER_FROM_HERE),
46 state_machine_(settings), 42 state_machine_(settings),
47 inside_process_scheduled_actions_(false),
48 inside_action_(SchedulerStateMachine::ACTION_NONE),
49 stopped_(false),
50 weak_factory_(this) { 43 weak_factory_(this) {
51 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue()); 44 TRACE_EVENT1("cc", "Scheduler::Scheduler", "settings", settings_.AsValue());
52 DCHECK(client_); 45 DCHECK(client_);
53 DCHECK(!state_machine_.BeginFrameNeeded()); 46 DCHECK(!state_machine_.BeginFrameNeeded());
54 47
55 begin_impl_frame_deadline_closure_ = base::Bind( 48 begin_impl_frame_deadline_closure_ = base::Bind(
56 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr()); 49 &Scheduler::OnBeginImplFrameDeadline, weak_factory_.GetWeakPtr());
57 50
58 ProcessScheduledActions(); 51 ProcessScheduledActions();
59 } 52 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 BeginFrameArgs adjusted_args = args; 317 BeginFrameArgs adjusted_args = args;
325 // Cancel the missed begin frame task in case the BFS sends a begin frame 318 // Cancel the missed begin frame task in case the BFS sends a begin frame
326 // before the missed frame task runs. 319 // before the missed frame task runs.
327 missed_begin_frame_task_.Cancel(); 320 missed_begin_frame_task_.Cancel();
328 321
329 base::TimeTicks now = Now(); 322 base::TimeTicks now = Now();
330 323
331 // Discard missed begin frames if they are too late. 324 // Discard missed begin frames if they are too late.
332 if (adjusted_args.type == BeginFrameArgs::MISSED && 325 if (adjusted_args.type == BeginFrameArgs::MISSED &&
333 now > adjusted_args.deadline) { 326 now > adjusted_args.deadline) {
327 skipped_last_frame_missed_exceeded_deadline_ = true;
334 SendBeginFrameAck(adjusted_args, kBeginFrameSkipped); 328 SendBeginFrameAck(adjusted_args, kBeginFrameSkipped);
335 return; 329 return;
336 } 330 }
337 331
332 skipped_last_frame_missed_exceeded_deadline_ = false;
333
338 // Run the previous deadline if any. 334 // Run the previous deadline if any.
339 if (state_machine_.begin_impl_frame_state() == 335 if (state_machine_.begin_impl_frame_state() ==
340 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) { 336 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) {
341 OnBeginImplFrameDeadline(); 337 OnBeginImplFrameDeadline();
342 // We may not need begin frames any longer. 338 // We may not need begin frames any longer.
343 if (!observing_begin_frame_source_) { 339 if (!observing_begin_frame_source_) {
344 // We need to confirm the ignored BeginFrame, since we don't have updates. 340 // We need to confirm the ignored BeginFrame, since we don't have updates.
345 // To persist the confirmation for future BeginFrameAcks, we let the state 341 // To persist the confirmation for future BeginFrameAcks, we let the state
346 // machine know about the BeginFrame. 342 // machine know about the BeginFrame.
347 state_machine_.OnBeginFrameDroppedNotObserving(args.source_id, 343 state_machine_.OnBeginFrameDroppedNotObserving(args.source_id,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 bmf_to_activate_estimate, now); 394 bmf_to_activate_estimate, now);
399 395
400 if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) { 396 if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) {
401 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency", 397 TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency",
402 TRACE_EVENT_SCOPE_THREAD); 398 TRACE_EVENT_SCOPE_THREAD);
403 state_machine_.SetSkipNextBeginMainFrameToReduceLatency(); 399 state_machine_.SetSkipNextBeginMainFrameToReduceLatency();
404 } else if (ShouldRecoverImplLatency(adjusted_args, 400 } else if (ShouldRecoverImplLatency(adjusted_args,
405 can_activate_before_deadline)) { 401 can_activate_before_deadline)) {
406 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency", 402 TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency",
407 TRACE_EVENT_SCOPE_THREAD); 403 TRACE_EVENT_SCOPE_THREAD);
404 skipped_last_frame_to_reduce_latency_ = true;
408 SendBeginFrameAck(begin_main_frame_args_, kBeginFrameSkipped); 405 SendBeginFrameAck(begin_main_frame_args_, kBeginFrameSkipped);
409 return; 406 return;
410 } 407 }
411 408
409 skipped_last_frame_to_reduce_latency_ = false;
410
412 BeginImplFrame(adjusted_args, now); 411 BeginImplFrame(adjusted_args, now);
413 } 412 }
414 413
415 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) { 414 void Scheduler::BeginImplFrameSynchronous(const BeginFrameArgs& args) {
416 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args", 415 TRACE_EVENT1("cc,benchmark", "Scheduler::BeginImplFrame", "args",
417 args.AsValue()); 416 args.AsValue());
418 // The main thread currently can't commit before we draw with the 417 // The main thread currently can't commit before we draw with the
419 // synchronous compositor, so never consider the BeginMainFrame fast. 418 // synchronous compositor, so never consider the BeginMainFrame fast.
420 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(false); 419 state_machine_.SetCriticalBeginMainFrameToActivateIsFast(false);
421 begin_main_frame_args_ = args; 420 begin_main_frame_args_ = args;
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 } 672 }
674 } 673 }
675 } while (action != SchedulerStateMachine::ACTION_NONE); 674 } while (action != SchedulerStateMachine::ACTION_NONE);
676 675
677 ScheduleBeginImplFrameDeadlineIfNeeded(); 676 ScheduleBeginImplFrameDeadlineIfNeeded();
678 SetupNextBeginFrameIfNeeded(); 677 SetupNextBeginFrameIfNeeded();
679 } 678 }
680 679
681 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 680 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
682 Scheduler::AsValue() const { 681 Scheduler::AsValue() const {
683 std::unique_ptr<base::trace_event::TracedValue> state( 682 auto state = base::MakeUnique<base::trace_event::TracedValue>();
684 new base::trace_event::TracedValue()); 683 AsValueInto(state.get());
684 return std::move(state);
685 }
686
687 void Scheduler::AsValueInto(base::trace_event::TracedValue* state) const {
685 base::TimeTicks now = Now(); 688 base::TimeTicks now = Now();
686 689
687 state->BeginDictionary("state_machine"); 690 state->BeginDictionary("state_machine");
688 state_machine_.AsValueInto(state.get()); 691 state_machine_.AsValueInto(state);
689 state->EndDictionary(); 692 state->EndDictionary();
690 693
691 state->BeginDictionary("scheduler_state");
692 state->SetBoolean("observing_begin_frame_source", 694 state->SetBoolean("observing_begin_frame_source",
693 observing_begin_frame_source_); 695 observing_begin_frame_source_);
694 state->SetBoolean("begin_impl_frame_deadline_task", 696 state->SetBoolean("begin_impl_frame_deadline_task",
695 !begin_impl_frame_deadline_task_.IsCancelled()); 697 !begin_impl_frame_deadline_task_.IsCancelled());
696 state->SetBoolean("missed_begin_frame_task", 698 state->SetBoolean("missed_begin_frame_task",
697 !missed_begin_frame_task_.IsCancelled()); 699 !missed_begin_frame_task_.IsCancelled());
700 state->SetBoolean("skipped_last_frame_missed_exceeded_deadline",
701 skipped_last_frame_missed_exceeded_deadline_);
702 state->SetBoolean("skipped_last_frame_to_reduce_latency",
703 skipped_last_frame_to_reduce_latency_);
698 state->SetString("inside_action", 704 state->SetString("inside_action",
699 SchedulerStateMachine::ActionToString(inside_action_)); 705 SchedulerStateMachine::ActionToString(inside_action_));
706 state->SetString("begin_impl_frame_deadline_mode",
707 SchedulerStateMachine::BeginImplFrameDeadlineModeToString(
708 begin_impl_frame_deadline_mode_));
700 709
701 state->BeginDictionary("begin_impl_frame_args"); 710 state->BeginDictionary("begin_impl_frame_args");
702 begin_impl_frame_tracker_.AsValueInto(now, state.get()); 711 begin_impl_frame_tracker_.AsValueInto(now, state);
703 state->EndDictionary(); 712 state->EndDictionary();
704 713
705 state->SetString("begin_impl_frame_deadline_mode_", 714 state->BeginDictionary("begin_frame_observer_state");
706 SchedulerStateMachine::BeginImplFrameDeadlineModeToString( 715 BeginFrameObserverBase::AsValueInto(state);
707 begin_impl_frame_deadline_mode_));
708 state->EndDictionary(); 716 state->EndDictionary();
709 717
718 if (begin_frame_source_) {
719 state->BeginDictionary("begin_frame_source_state");
720 begin_frame_source_->AsValueInto(state);
721 state->EndDictionary();
722 }
723
710 state->BeginDictionary("compositor_timing_history"); 724 state->BeginDictionary("compositor_timing_history");
711 compositor_timing_history_->AsValueInto(state.get()); 725 compositor_timing_history_->AsValueInto(state);
712 state->EndDictionary(); 726 state->EndDictionary();
713
714 return std::move(state);
715 } 727 }
716 728
717 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() { 729 void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() {
718 compositor_timing_history_->SetRecordingEnabled( 730 compositor_timing_history_->SetRecordingEnabled(
719 state_machine_.HasInitializedCompositorFrameSink() && 731 state_machine_.HasInitializedCompositorFrameSink() &&
720 state_machine_.visible()); 732 state_machine_.visible());
721 } 733 }
722 734
723 bool Scheduler::ShouldRecoverMainLatency( 735 bool Scheduler::ShouldRecoverMainLatency(
724 const BeginFrameArgs& args, 736 const BeginFrameArgs& args,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 811 }
800 812
801 BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const { 813 BeginFrameAck Scheduler::CurrentBeginFrameAckForActiveTree() const {
802 return BeginFrameAck( 814 return BeginFrameAck(
803 begin_main_frame_args_.source_id, begin_main_frame_args_.sequence_number, 815 begin_main_frame_args_.source_id, begin_main_frame_args_.sequence_number,
804 state_machine_.last_begin_frame_sequence_number_active_tree_was_fresh(), 816 state_machine_.last_begin_frame_sequence_number_active_tree_was_fresh(),
805 true); 817 true);
806 } 818 }
807 819
808 } // namespace cc 820 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698