summaryrefslogtreecommitdiff
path: root/chromium/cc/scheduler
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/cc/scheduler
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/cc/scheduler')
-rw-r--r--chromium/cc/scheduler/commit_earlyout_reason.h2
-rw-r--r--chromium/cc/scheduler/scheduler.cc33
-rw-r--r--chromium/cc/scheduler/scheduler.h15
-rw-r--r--chromium/cc/scheduler/scheduler_state_machine.cc2
-rw-r--r--chromium/cc/scheduler/scheduler_state_machine.h8
-rw-r--r--chromium/cc/scheduler/scheduler_unittest.cc48
6 files changed, 66 insertions, 42 deletions
diff --git a/chromium/cc/scheduler/commit_earlyout_reason.h b/chromium/cc/scheduler/commit_earlyout_reason.h
index 61c1c93d4c9..4dc8b98462b 100644
--- a/chromium/cc/scheduler/commit_earlyout_reason.h
+++ b/chromium/cc/scheduler/commit_earlyout_reason.h
@@ -5,7 +5,7 @@
#ifndef CC_SCHEDULER_COMMIT_EARLYOUT_REASON_H_
#define CC_SCHEDULER_COMMIT_EARLYOUT_REASON_H_
-#include "base/logging.h"
+#include "base/notreached.h"
#include "cc/cc_export.h"
namespace cc {
diff --git a/chromium/cc/scheduler/scheduler.cc b/chromium/cc/scheduler/scheduler.cc
index 445e0696639..8292ee70801 100644
--- a/chromium/cc/scheduler/scheduler.cc
+++ b/chromium/cc/scheduler/scheduler.cc
@@ -516,20 +516,19 @@ void Scheduler::BeginImplFrameWithDeadline(const viz::BeginFrameArgs& args) {
->BeginMainFrameQueueDurationNotCriticalEstimate();
}
- // We defer the invalidation if we expect the main thread to respond within
- // this frame, and our prediction in the last frame was correct. That
- // is, if we predicted the main thread to be fast and it fails to respond
- // before the deadline in the previous frame, we don't defer the invalidation
- // in the next frame.
- const bool main_thread_response_expected_before_deadline =
- bmf_sent_to_ready_to_commit_estimate - time_since_main_frame_sent <
- bmf_to_activate_threshold;
- const bool previous_invalidation_maybe_skipped_for_main_frame =
- state_machine_.should_defer_invalidation_for_fast_main_frame() &&
- state_machine_.main_thread_failed_to_respond_last_deadline();
+ bool main_thread_response_expected_before_deadline;
+ if (time_since_main_frame_sent > bmf_to_activate_threshold) {
+ // If the response to a main frame is pending past the desired duration
+ // then proactively assume that the main thread is slow instead of late
+ // correction through the frame history.
+ main_thread_response_expected_before_deadline = false;
+ } else {
+ main_thread_response_expected_before_deadline =
+ bmf_sent_to_ready_to_commit_estimate - time_since_main_frame_sent <
+ bmf_to_activate_threshold;
+ }
state_machine_.set_should_defer_invalidation_for_fast_main_frame(
- main_thread_response_expected_before_deadline &&
- !previous_invalidation_maybe_skipped_for_main_frame);
+ main_thread_response_expected_before_deadline);
base::TimeDelta bmf_to_activate_estimate = bmf_to_activate_estimate_critical;
if (!begin_main_frame_args_.on_critical_path) {
@@ -594,7 +593,7 @@ void Scheduler::FinishImplFrame() {
DCHECK(!inside_scheduled_action_);
{
base::AutoReset<bool> mark_inside(&inside_scheduled_action_, true);
- client_->DidFinishImplFrame();
+ client_->DidFinishImplFrame(last_activate_origin_frame_args());
}
if (begin_frame_source_)
@@ -745,9 +744,6 @@ void Scheduler::DrawIfPossible() {
state_machine_.DidDraw(result);
compositor_timing_history_->DidDraw(
drawing_with_new_active_tree,
- client_->CompositedAnimationsCount(),
- client_->MainThreadAnimationsCount(), client_->CurrentFrameHadRAF(),
- client_->NextFrameHasPendingRAF(),
client_->HasCustomPropertyAnimations());
}
@@ -763,9 +759,6 @@ void Scheduler::DrawForced() {
state_machine_.DidDraw(result);
compositor_timing_history_->DidDraw(
drawing_with_new_active_tree,
- client_->CompositedAnimationsCount(),
- client_->MainThreadAnimationsCount(), client_->CurrentFrameHadRAF(),
- client_->NextFrameHasPendingRAF(),
client_->HasCustomPropertyAnimations());
}
diff --git a/chromium/cc/scheduler/scheduler.h b/chromium/cc/scheduler/scheduler.h
index 750e44b4614..0265dc0c3ac 100644
--- a/chromium/cc/scheduler/scheduler.h
+++ b/chromium/cc/scheduler/scheduler.h
@@ -69,7 +69,13 @@ class SchedulerClient {
virtual void ScheduledActionInvalidateLayerTreeFrameSink(
bool needs_redraw) = 0;
virtual void ScheduledActionPerformImplSideInvalidation() = 0;
- virtual void DidFinishImplFrame() = 0;
+ // Called when the scheduler is done processing a frame. Note that the
+ // BeginFrameArgs instance passed may not necessarily be the same instance
+ // that was passed to WillBeginImplFrame(). Rather, |last_activated_args|
+ // represents the latest BeginFrameArgs instance that caused an activation to
+ // happen.
+ virtual void DidFinishImplFrame(
+ const viz::BeginFrameArgs& last_activated_args) = 0;
virtual void DidNotProduceFrame(const viz::BeginFrameAck& ack,
FrameSkippedReason reason) = 0;
virtual void WillNotReceiveBeginFrame() = 0;
@@ -79,11 +85,7 @@ class SchedulerClient {
virtual void FrameIntervalUpdated(base::TimeDelta interval) = 0;
// Functions used for reporting animation targeting UMA, crbug.com/758439.
- virtual size_t CompositedAnimationsCount() const = 0;
- virtual size_t MainThreadAnimationsCount() const = 0;
virtual bool HasCustomPropertyAnimations() const = 0;
- virtual bool CurrentFrameHadRAF() const = 0;
- virtual bool NextFrameHasPendingRAF() const = 0;
protected:
virtual ~SchedulerClient() {}
@@ -281,7 +283,8 @@ class CC_EXPORT Scheduler : public viz::BeginFrameObserverBase {
// What the latest deadline was, and when it was scheduled.
base::TimeTicks deadline_;
base::TimeTicks deadline_scheduled_at_;
- SchedulerStateMachine::BeginImplFrameDeadlineMode deadline_mode_;
+ SchedulerStateMachine::BeginImplFrameDeadlineMode deadline_mode_ =
+ SchedulerStateMachine::BeginImplFrameDeadlineMode::NONE;
BeginFrameTracker begin_impl_frame_tracker_;
viz::BeginFrameAck last_begin_frame_ack_;
diff --git a/chromium/cc/scheduler/scheduler_state_machine.cc b/chromium/cc/scheduler/scheduler_state_machine.cc
index e69c54ce465..2dcc5e4bba7 100644
--- a/chromium/cc/scheduler/scheduler_state_machine.cc
+++ b/chromium/cc/scheduler/scheduler_state_machine.cc
@@ -1191,8 +1191,6 @@ void SchedulerStateMachine::OnBeginImplFrameIdle() {
// then the main thread is in a high latency mode.
main_thread_missed_last_deadline_ =
CommitPending() || has_pending_tree_ || active_tree_needs_first_draw_;
- main_thread_failed_to_respond_last_deadline_ =
- begin_main_frame_state_ == BeginMainFrameState::SENT;
// If we're entering a state where we won't get BeginFrames set all the
// funnels so that we don't perform any actions that we shouldn't.
diff --git a/chromium/cc/scheduler/scheduler_state_machine.h b/chromium/cc/scheduler/scheduler_state_machine.h
index f6a8d0a37f1..97b2571f99e 100644
--- a/chromium/cc/scheduler/scheduler_state_machine.h
+++ b/chromium/cc/scheduler/scheduler_state_machine.h
@@ -344,10 +344,6 @@ class CC_EXPORT SchedulerStateMachine {
return should_defer_invalidation_for_fast_main_frame_;
}
- bool main_thread_failed_to_respond_last_deadline() const {
- return main_thread_failed_to_respond_last_deadline_;
- }
-
protected:
bool BeginFrameRequiredForAction() const;
bool BeginFrameNeededForVideo() const;
@@ -471,10 +467,6 @@ class CC_EXPORT SchedulerStateMachine {
// tree. During this time we should not activate the pending tree.
bool processing_paint_worklets_for_pending_tree_ = false;
- // Set to true if the main thread fails to respond with a commit or abort the
- // main frame before the draw deadline on the previous impl frame.
- bool main_thread_failed_to_respond_last_deadline_ = false;
-
bool previous_pending_tree_was_impl_side_ = false;
bool current_pending_tree_is_impl_side_ = false;
diff --git a/chromium/cc/scheduler/scheduler_unittest.cc b/chromium/cc/scheduler/scheduler_unittest.cc
index 4ce0028b0f3..e4be2b3e68b 100644
--- a/chromium/cc/scheduler/scheduler_unittest.cc
+++ b/chromium/cc/scheduler/scheduler_unittest.cc
@@ -121,7 +121,8 @@ class FakeSchedulerClient : public SchedulerClient,
scheduler_->SetNeedsRedraw();
return will_begin_impl_frame_might_have_damage_;
}
- void DidFinishImplFrame() override {
+ void DidFinishImplFrame(
+ const viz::BeginFrameArgs& last_activated_args) override {
EXPECT_TRUE(inside_begin_impl_frame_);
EXPECT_FALSE(inside_action_);
base::AutoReset<bool> mark_inside(&inside_action_, true);
@@ -262,11 +263,7 @@ class FakeSchedulerClient : public SchedulerClient,
PushAction("RemoveObserver(this)");
}
- size_t CompositedAnimationsCount() const override { return 0; }
- size_t MainThreadAnimationsCount() const override { return 0; }
bool HasCustomPropertyAnimations() const override { return false; }
- bool CurrentFrameHadRAF() const override { return false; }
- bool NextFrameHasPendingRAF() const override { return false; }
protected:
bool InsideBeginImplFrameCallback(bool state) {
@@ -4361,5 +4358,46 @@ TEST_F(SchedulerTest, SendEarlyDidNotProduceFrameIfIdle) {
begin_main_frame_args.frame_id.sequence_number);
}
+TEST_F(SchedulerTest,
+ HighImplLatencyModePrioritizesMainFramesOverImplInvalidation) {
+ scheduler_settings_.enable_main_latency_recovery = false;
+ scheduler_settings_.enable_impl_latency_recovery = false;
+ SetUpScheduler(EXTERNAL_BFS);
+ fake_compositor_timing_history_->SetAllEstimatesTo(kFastDuration);
+
+ // Place the impl thread in high latency mode.
+ scheduler_->SetNeedsImplSideInvalidation(true);
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_ACTIONS("WillBeginImplFrame",
+ "ScheduledActionPerformImplSideInvalidation");
+
+ // Request a main frame and start the next impl frame. Since we have an impl
+ // side pending tree, we will activate and draw it. This finishes the impl
+ // frame before the main thread can respond causing the scheduler to
+ // incorrectly assume the main thread is slow.
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ EXPECT_ACTIONS("WillBeginImplFrame");
+ client_->Reset();
+ scheduler_->SetNeedsBeginMainFrame();
+ EXPECT_ACTIONS("ScheduledActionSendBeginMainFrame");
+ fake_compositor_timing_history_->SetBeginMainFrameSentTime(
+ task_runner_->NowTicks() + base::TimeDelta::FromMilliseconds(8));
+ client_->Reset();
+ scheduler_->NotifyReadyToActivate();
+ task_runner_->RunTasksWhile(client_->InsideBeginImplFrame(true));
+ EXPECT_ACTIONS("ScheduledActionActivateSyncTree",
+ "ScheduledActionDrawIfPossible");
+
+ // Start a new frame. We should not assume the main thread is slow.
+ client_->Reset();
+ EXPECT_SCOPED(AdvanceFrame());
+ scheduler_->SetNeedsImplSideInvalidation(true);
+ // No invalidation should be performed since we are waiting for the main
+ // thread to respond and merge with the commit.
+ EXPECT_ACTIONS("WillBeginImplFrame");
+}
+
} // namespace
} // namespace cc