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

Unified Diff: cc/scheduler/scheduler.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: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: cc/scheduler/scheduler.cc
diff --git a/cc/scheduler/scheduler.cc b/cc/scheduler/scheduler.cc
index b21eacb3932c205587c64060d268af1845a05159..bffd65208930cac46e78f2992e27568b86fe36a0 100644
--- a/cc/scheduler/scheduler.cc
+++ b/cc/scheduler/scheduler.cc
@@ -210,8 +210,10 @@ void Scheduler::DidSwapBuffersComplete() {
ProcessScheduledActions();
}
-void Scheduler::SetImplLatencyTakesPriority(bool impl_latency_takes_priority) {
- state_machine_.SetImplLatencyTakesPriority(impl_latency_takes_priority);
+void Scheduler::SetSmoothnessMode(bool smoothness_takes_priority,
+ bool scroll_affects_scroll_handler) {
+ state_machine_.SetSmoothnessMode(smoothness_takes_priority,
+ scroll_affects_scroll_handler);
ProcessScheduledActions();
}
@@ -463,11 +465,21 @@ void Scheduler::BeginImplFrameWithDeadline(const BeginFrameArgs& args) {
adjusted_args.deadline -= compositor_timing_history_->DrawDurationEstimate();
adjusted_args.deadline -= kDeadlineFudgeFactor;
- if (ShouldRecoverMainLatency(adjusted_args)) {
+ base::TimeDelta bmf_to_activate_estimate =
+ compositor_timing_history_->BeginMainFrameToCommitDurationEstimate() +
+ compositor_timing_history_->CommitToReadyToActivateDurationEstimate() +
+ compositor_timing_history_->ActivateDurationEstimate();
+
+ state_machine_.SetMainThreadIsFast(bmf_to_activate_estimate < args.interval);
Sami 2015/10/29 10:53:56 This part I'm a little unsure about. The delay of
brianderson 2015/10/29 17:56:51 What if we: 1) Make adjusted_args.on_critical_path
Sami 2015/10/29 18:37:04 I like both ideas!
+
+ bool can_activate_before_deadline = CanCommitAndActivateBeforeDeadline(
+ adjusted_args, bmf_to_activate_estimate);
+ if (ShouldRecoverMainLatency(adjusted_args, can_activate_before_deadline)) {
TRACE_EVENT_INSTANT0("cc", "SkipBeginMainFrameToReduceLatency",
TRACE_EVENT_SCOPE_THREAD);
state_machine_.SetSkipNextBeginMainFrameToReduceLatency();
- } else if (ShouldRecoverImplLatency(adjusted_args)) {
+ } else if (ShouldRecoverImplLatency(adjusted_args,
+ can_activate_before_deadline)) {
TRACE_EVENT_INSTANT0("cc", "SkipBeginImplFrameToReduceLatency",
TRACE_EVENT_SCOPE_THREAD);
frame_source_->DidFinishFrame(begin_retro_frame_args_.size());
@@ -776,7 +788,9 @@ void Scheduler::UpdateCompositorTimingHistoryRecordingEnabled() {
state_machine_.HasInitializedOutputSurface() && state_machine_.visible());
}
-bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const {
+bool Scheduler::ShouldRecoverMainLatency(
+ const BeginFrameArgs& args,
+ bool can_activate_before_deadline) const {
DCHECK(!settings_.using_synchronous_renderer_compositor);
if (!state_machine_.main_thread_missed_last_deadline())
@@ -784,13 +798,15 @@ bool Scheduler::ShouldRecoverMainLatency(const BeginFrameArgs& args) const {
// When prioritizing impl thread latency, we currently put the
// main thread in a high latency mode. Don't try to fight it.
- if (state_machine_.impl_latency_takes_priority())
+ if (state_machine_.ImplLatencyTakesPriority())
return false;
- return CanCommitAndActivateBeforeDeadline(args);
+ return can_activate_before_deadline;
}
-bool Scheduler::ShouldRecoverImplLatency(const BeginFrameArgs& args) const {
+bool Scheduler::ShouldRecoverImplLatency(
+ const BeginFrameArgs& args,
+ bool can_activate_before_deadline) const {
DCHECK(!settings_.using_synchronous_renderer_compositor);
// Disable impl thread latency recovery when using the unthrottled
@@ -810,7 +826,7 @@ bool Scheduler::ShouldRecoverImplLatency(const BeginFrameArgs& args) const {
// When prioritizing impl thread latency, the deadline doesn't wait
// for the main thread.
- if (state_machine_.impl_latency_takes_priority())
+ if (state_machine_.ImplLatencyTakesPriority())
return can_draw_before_deadline;
// If we only have impl-side updates, the deadline doesn't wait for
@@ -822,18 +838,16 @@ bool Scheduler::ShouldRecoverImplLatency(const BeginFrameArgs& args) const {
// to the impl thread. In this case, only try to also recover impl thread
// latency if both the main and impl threads can run serially before the
// deadline.
- return CanCommitAndActivateBeforeDeadline(args);
+ return can_activate_before_deadline;
}
bool Scheduler::CanCommitAndActivateBeforeDeadline(
- const BeginFrameArgs& args) const {
+ const BeginFrameArgs& args,
+ base::TimeDelta bmf_to_activate_estimate) const {
// Check if the main thread computation and commit can be finished before the
// impl thread's deadline.
base::TimeTicks estimated_draw_time =
- args.frame_time +
- compositor_timing_history_->BeginMainFrameToCommitDurationEstimate() +
- compositor_timing_history_->CommitToReadyToActivateDurationEstimate() +
- compositor_timing_history_->ActivateDurationEstimate();
+ args.frame_time + bmf_to_activate_estimate;
return estimated_draw_time < args.deadline;
}

Powered by Google App Engine
This is Rietveld 408576698