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

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

Issue 2418593002: Fix scheduler bug in skipping main frames (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « no previous file | cc/scheduler/scheduler_unittest.cc » ('j') | cc/scheduler/scheduler_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) { 312 void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) {
313 // The storage for |args| is owned by the missed begin frame task. Therefore 313 // The storage for |args| is owned by the missed begin frame task. Therefore
314 // save |args| before cancelling the task either here or in the deadline. 314 // save |args| before cancelling the task either here or in the deadline.
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 // Discard missed begin frames if they are too late. 320 // Discard missed begin frames if they are too late.
321 if (adjusted_args.type == BeginFrameArgs::MISSED && 321 if (adjusted_args.type == BeginFrameArgs::MISSED &&
322 Now() > adjusted_args.deadline) { 322 Now() > adjusted_args.deadline) {
brianderson 2016/10/12 20:38:17 Would it work to store this Now() and use it in bo
enne (OOO) 2016/10/13 17:09:44 Done.
enne (OOO) 2016/10/13 17:09:44 Done.
323 begin_frame_source_->DidFinishFrame(this, 0); 323 begin_frame_source_->DidFinishFrame(this, 0);
324 return; 324 return;
325 } 325 }
326 326
327 // Run the previous deadline if any. 327 // Run the previous deadline if any.
328 if (state_machine_.begin_impl_frame_state() == 328 if (state_machine_.begin_impl_frame_state() ==
329 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) { 329 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME) {
330 OnBeginImplFrameDeadline(); 330 OnBeginImplFrameDeadline();
331 // We may not need begin frames any longer. 331 // We may not need begin frames any longer.
332 if (!observing_begin_frame_source_) { 332 if (!observing_begin_frame_source_) {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 // latency if both the main and impl threads can run serially before the 735 // latency if both the main and impl threads can run serially before the
736 // deadline. 736 // deadline.
737 return can_activate_before_deadline; 737 return can_activate_before_deadline;
738 } 738 }
739 739
740 bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline( 740 bool Scheduler::CanBeginMainFrameAndActivateBeforeDeadline(
741 const BeginFrameArgs& args, 741 const BeginFrameArgs& args,
742 base::TimeDelta bmf_to_activate_estimate) const { 742 base::TimeDelta bmf_to_activate_estimate) const {
743 // Check if the main thread computation and commit can be finished before the 743 // Check if the main thread computation and commit can be finished before the
744 // impl thread's deadline. 744 // impl thread's deadline.
745 base::TimeTicks estimated_draw_time = 745 base::TimeTicks estimated_draw_time = Now() + bmf_to_activate_estimate;
746 args.frame_time + bmf_to_activate_estimate;
747 746
748 return estimated_draw_time < args.deadline; 747 return estimated_draw_time < args.deadline;
749 } 748 }
750 749
751 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 750 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
752 return (state_machine_.begin_main_frame_state() == 751 return (state_machine_.begin_main_frame_state() ==
753 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || 752 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT ||
754 state_machine_.begin_main_frame_state() == 753 state_machine_.begin_main_frame_state() ==
755 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); 754 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED);
756 } 755 }
757 756
758 } // namespace cc 757 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/scheduler/scheduler_unittest.cc » ('j') | cc/scheduler/scheduler_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698