0

[Part 2] Rename ThroughputTracker to CompositorMetricsTracker

ThroughputTracker can track any compositor metrics over a sequence of
time. It current name reflect its usage to collect smoothness related
metrics. However, we want to use mechanism to track other metrics
(paint) as well. The naming convention should reflect this
genericness.

In crrev.com/c/6040362, we did renaming in ui/compositor and ash/
directories. In this CL, we are renaming cc/ and blink/ directories. (mostly)

Bug: b:380318532
Change-Id: I71e60a3312d30224b77fa51dbf04ebbc55837f3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6042895
Commit-Queue: Zoraiz Naeem <zoraiznaeem@chromium.org>
Reviewed-by: Stefan Zager <szager@chromium.org>
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1387187}
This commit is contained in:
Zoraiz Naeem
2024-11-23 01:26:07 +00:00
committed by Chromium LUCI CQ
parent 252b1315a4
commit 48de4863fa
26 changed files with 89 additions and 68 deletions

@ -446,9 +446,10 @@ void AnimationHost::PushPropertiesToImplThread(AnimationHost* host_impl) {
// The pending info list is cleared in LayerTreeHostImpl::CommitComplete
// and should be empty when pushing properties.
DCHECK(host_impl->pending_throughput_tracker_infos_.Read(*host_impl).empty());
host_impl->pending_throughput_tracker_infos_.Write(*host_impl) =
TakePendingThroughputTrackerInfos();
DCHECK(host_impl->pending_compositor_metrics_tracker_infos_.Read(*host_impl)
.empty());
host_impl->pending_compositor_metrics_tracker_infos_.Write(*host_impl) =
TakePendingCompositorMetricsTrackerInfos();
}
const ElementAnimations* AnimationHost::GetElementAnimationsForElementId(
@ -926,24 +927,25 @@ bool AnimationHost::HasNativePropertyAnimation() const {
return false;
}
AnimationHost::PendingThroughputTrackerInfos
AnimationHost::TakePendingThroughputTrackerInfos() {
PendingThroughputTrackerInfos infos =
std::move(pending_throughput_tracker_infos_.Write(*this));
pending_throughput_tracker_infos_.Write(*this) = {};
AnimationHost::PendingCompositorMetricsTrackerInfos
AnimationHost::TakePendingCompositorMetricsTrackerInfos() {
PendingCompositorMetricsTrackerInfos infos =
std::move(pending_compositor_metrics_tracker_infos_.Write(*this));
pending_compositor_metrics_tracker_infos_.Write(*this) = {};
return infos;
}
void AnimationHost::StartThroughputTracking(
void AnimationHost::StartCompositorMetricsTracking(
TrackedAnimationSequenceId sequence_id) {
pending_throughput_tracker_infos_.Write(*this).push_back({sequence_id, true});
pending_compositor_metrics_tracker_infos_.Write(*this).push_back(
{sequence_id, true});
SetNeedsPushProperties();
}
void AnimationHost::StopThroughputTracking(
TrackedAnimationSequenceId sequnece_id) {
pending_throughput_tracker_infos_.Write(*this).push_back(
{sequnece_id, false});
void AnimationHost::StopCompositorMetricsTracking(
TrackedAnimationSequenceId sequence_id) {
pending_compositor_metrics_tracker_infos_.Write(*this).push_back(
{sequence_id, false});
SetNeedsPushProperties();
}

@ -224,16 +224,17 @@ class CC_ANIMATION_EXPORT AnimationHost : public MutatorHost,
bool HasNativePropertyAnimation() const override;
bool CurrentFrameHadRAF() const override;
bool NextFrameHasPendingRAF() const override;
PendingThroughputTrackerInfos TakePendingThroughputTrackerInfos() override;
PendingCompositorMetricsTrackerInfos
TakePendingCompositorMetricsTrackerInfos() override;
bool HasCanvasInvalidation() const override;
bool HasJSAnimation() const override;
bool HasSmilAnimation() const override;
bool HasViewTransition() const override;
bool HasScrollLinkedAnimation(ElementId for_scroller) const override;
// Starts/stops throughput tracking represented by |sequence_id|.
void StartThroughputTracking(TrackedAnimationSequenceId sequence_id);
void StopThroughputTracking(TrackedAnimationSequenceId sequnece_id);
// Starts/stops metrics tracking represented by `sequence_id`.
void StartCompositorMetricsTracking(TrackedAnimationSequenceId sequence_id);
void StopCompositorMetricsTracking(TrackedAnimationSequenceId sequence_id);
void SetAnimationCounts(size_t total_animations_count);
void SetHasCanvasInvalidation(bool has_canvas_invalidation);
@ -314,8 +315,8 @@ class CC_ANIMATION_EXPORT AnimationHost : public MutatorHost,
ProtectedSequenceReadable<bool> has_smil_animation_{false};
ProtectedSequenceReadable<bool> has_view_transition_{false};
ProtectedSequenceWritable<PendingThroughputTrackerInfos>
pending_throughput_tracker_infos_;
ProtectedSequenceWritable<PendingCompositorMetricsTrackerInfos>
pending_compositor_metrics_tracker_infos_;
base::WeakPtrFactory<AnimationHost> weak_factory_{this};
};

@ -55,7 +55,8 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient {
ElementListType tree_type) override {}
void NotifyPaintWorkletStateChange(
Scheduler::PaintWorkletState state) override {}
void NotifyThroughputTrackerResults(CustomTrackerResults results) override {}
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override {}
void DidObserveFirstScrollDelay(
int source_frame_number,
base::TimeDelta first_scroll_delay,

@ -439,8 +439,9 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient,
std::unique_ptr<BeginMainFrameMetrics> GetBeginMainFrameMetrics() override {
return test_hooks_->GetBeginMainFrameMetrics();
}
void NotifyThroughputTrackerResults(CustomTrackerResults results) override {
test_hooks_->NotifyThroughputTrackerResults(std::move(results));
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override {
test_hooks_->NotifyCompositorMetricsTrackerResults(std::move(results));
}
void UpdateLayerTreeHost() override { test_hooks_->UpdateLayerTreeHost(); }

@ -36,7 +36,8 @@ class StubLayerTreeHostClient : public LayerTreeHostClient {
void RecordEndOfFrameMetrics(base::TimeTicks,
ActiveFrameSequenceTrackers) override {}
std::unique_ptr<BeginMainFrameMetrics> GetBeginMainFrameMetrics() override;
void NotifyThroughputTrackerResults(CustomTrackerResults results) override {}
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override {}
void BeginMainFrameNotExpectedSoon() override {}
void BeginMainFrameNotExpectedUntil(base::TimeTicks time) override {}
void UpdateLayerTreeHost() override {}

@ -119,7 +119,8 @@ class TestHooks : public AnimationDelegate {
virtual void DidCommit() {}
virtual void DidCommitAndDrawFrame() {}
virtual void DidActivateSyncTree() {}
virtual void NotifyThroughputTrackerResults(CustomTrackerResults results) {}
virtual void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) {}
virtual std::unique_ptr<BeginMainFrameMetrics> GetBeginMainFrameMetrics();
virtual void DidPresentCompositorFrame(
uint32_t frame_token,

@ -1206,10 +1206,10 @@ void LayerTreeHost::RecordEndOfFrameMetrics(
client_->RecordEndOfFrameMetrics(frame_begin_time, trackers);
}
void LayerTreeHost::NotifyThroughputTrackerResults(
void LayerTreeHost::NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) {
DCHECK(IsMainThread());
client_->NotifyThroughputTrackerResults(std::move(results));
client_->NotifyCompositorMetricsTrackerResults(std::move(results));
}
const base::WeakPtr<CompositorDelegateForInput>&

@ -786,7 +786,7 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
void RecordStartOfFrameMetrics();
void RecordEndOfFrameMetrics(base::TimeTicks frame_begin_time,
ActiveFrameSequenceTrackers trackers);
void NotifyThroughputTrackerResults(CustomTrackerResults results);
void NotifyCompositorMetricsTrackerResults(CustomTrackerResults results);
void NotifyImageDecodeFinished(int request_id, bool decode_succeeded);
void NotifyTransitionRequestsFinished(
const uint32_t sequence_id,

@ -196,7 +196,8 @@ class CC_EXPORT LayerTreeHostClient {
// committed to the compositor, which is before the call to
// RecordEndOfFrameMetrics.
virtual std::unique_ptr<BeginMainFrameMetrics> GetBeginMainFrameMetrics() = 0;
virtual void NotifyThroughputTrackerResults(CustomTrackerResults results) = 0;
virtual void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) = 0;
virtual void RunPaintBenchmark(int repeat_count,
PaintBenchmarkResult& result) {}

@ -526,9 +526,9 @@ LayerTreeHostImpl::LayerTreeHostImpl(
}
dropped_frame_counter_.set_total_counter(&total_frame_counter_);
frame_trackers_.set_custom_tracker_results_added_callback(
base::BindRepeating(&LayerTreeHostImpl::NotifyThroughputTrackerResults,
weak_factory_.GetWeakPtr()));
frame_trackers_.set_custom_tracker_results_added_callback(base::BindRepeating(
&LayerTreeHostImpl::NotifyCompositorMetricsTrackerResults,
weak_factory_.GetWeakPtr()));
}
LayerTreeHostImpl::~LayerTreeHostImpl() {
@ -789,7 +789,8 @@ void LayerTreeHostImpl::CommitComplete() {
}
}
for (const auto& info : mutator_host_->TakePendingThroughputTrackerInfos()) {
for (const auto& info :
mutator_host_->TakePendingCompositorMetricsTrackerInfos()) {
const MutatorHost::TrackedAnimationSequenceId sequence_id = info.id;
const bool start = info.start;
if (start)
@ -2240,9 +2241,9 @@ void LayerTreeHostImpl::LogAverageLagEvents(
lag_tracking_manager_.DidPresentCompositorFrame(frame_token, details);
}
void LayerTreeHostImpl::NotifyThroughputTrackerResults(
void LayerTreeHostImpl::NotifyCompositorMetricsTrackerResults(
const CustomTrackerResults& results) {
client_->NotifyThroughputTrackerResults(results);
client_->NotifyCompositorMetricsTrackerResults(results);
}
void LayerTreeHostImpl::DidNotNeedBeginFrame() {

@ -172,7 +172,8 @@ class LayerTreeHostImplClient {
virtual void NotifyPaintWorkletStateChange(
Scheduler::PaintWorkletState state) = 0;
virtual void NotifyThroughputTrackerResults(CustomTrackerResults results) = 0;
virtual void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) = 0;
virtual void DidObserveFirstScrollDelay(
int source_frame_number,
@ -1069,7 +1070,8 @@ class CC_EXPORT LayerTreeHostImpl : public TileManagerClient,
const viz::FrameTimingDetails& details);
// Notifies client about the custom tracker results.
void NotifyThroughputTrackerResults(const CustomTrackerResults& results);
void NotifyCompositorMetricsTrackerResults(
const CustomTrackerResults& results);
// Wrapper for checking and updating |contains_srgb_cache_|.
bool CheckColorSpaceContainsSrgb(const gfx::ColorSpace& color_space) const;

@ -297,7 +297,8 @@ class LayerTreeHostImplTestBase : public testing::Test,
ElementListType tree_type) override {}
void NotifyPaintWorkletStateChange(
Scheduler::PaintWorkletState state) override {}
void NotifyThroughputTrackerResults(CustomTrackerResults results) override {}
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override {}
void DidObserveFirstScrollDelay(
int source_frame_number,

@ -8970,10 +8970,10 @@ class LayerTreeHostTopControlsDeltaTriggersViewportUpdate
MULTI_THREAD_TEST_F(LayerTreeHostTopControlsDeltaTriggersViewportUpdate);
#if BUILDFLAG(IS_CHROMEOS)
// Tests that custom sequence throughput tracking result is reported to
// Tests that custom sequence metrics tracking result is reported to
// LayerTreeHostClient.
constexpr MutatorHost::TrackedAnimationSequenceId kSequenceId = 1u;
class LayerTreeHostCustomThroughputTrackerTest : public LayerTreeHostTest {
class LayerTreeHostCustomMetricsTrackerTest : public LayerTreeHostTest {
public:
// Custom sequences are only supported for ChromeOS UI, which is
// Single-Threaded.
@ -8988,10 +8988,10 @@ class LayerTreeHostCustomThroughputTrackerTest : public LayerTreeHostTest {
// e(2,2)b(3)B(0,3)E(3)s(3)S(3)e(3,3)P(3)b(4)B(3,4)E(4)s(4)S(4)e(4,4)P(4)
switch (layer_tree_host()->SourceFrameNumber()) {
case 1:
animation_host()->StartThroughputTracking(kSequenceId);
animation_host()->StartCompositorMetricsTracking(kSequenceId);
break;
case 3:
animation_host()->StopThroughputTracking(kSequenceId);
animation_host()->StopCompositorMetricsTracking(kSequenceId);
break;
default:
break;
@ -9001,7 +9001,8 @@ class LayerTreeHostCustomThroughputTrackerTest : public LayerTreeHostTest {
PostSetNeedsCommitWithForcedRedrawToMainThread();
}
void NotifyThroughputTrackerResults(CustomTrackerResults results) override {
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override {
// Check that data for kSequenceId is captured. Ideally, we should get
// 2 frame_expected and 2 frame_produced. But on slow bots, it is difficult
// to infer the correct numbers. Both frame_expected and frame_produced
@ -9020,7 +9021,7 @@ class LayerTreeHostCustomThroughputTrackerTest : public LayerTreeHostTest {
}
};
SINGLE_THREAD_TEST_F(LayerTreeHostCustomThroughputTrackerTest);
SINGLE_THREAD_TEST_F(LayerTreeHostCustomMetricsTrackerTest);
#endif // BUILDFLAG(IS_CHROMEOS)
class LayerTreeHostTestDelegatedInkMetadataBase

@ -158,17 +158,20 @@ class MutatorHost {
virtual base::TimeDelta MinimumTickInterval() const = 0;
using TrackedAnimationSequenceId = size_t;
struct PendingThroughputTrackerInfo {
struct PendingCompositorMetricsTrackerInfo {
// Id of a tracked animation sequence.
TrackedAnimationSequenceId id = 0u;
// True means the tracking for |id| is pending to start and false means
// the tracking is pending to stop.
bool start = false;
};
// Takes info of throughput trackers that are pending start or stop.
using PendingThroughputTrackerInfos =
std::vector<PendingThroughputTrackerInfo>;
virtual PendingThroughputTrackerInfos TakePendingThroughputTrackerInfos() = 0;
// Takes info of compositor metrics trackers that are pending start or stop.
using PendingCompositorMetricsTrackerInfos =
std::vector<PendingCompositorMetricsTrackerInfo>;
virtual PendingCompositorMetricsTrackerInfos
TakePendingCompositorMetricsTrackerInfos() = 0;
};
class MutatorEvents {

@ -680,11 +680,13 @@ void ProxyImpl::NotifyPaintWorkletStateChange(
scheduler_->NotifyPaintWorkletStateChange(state);
}
void ProxyImpl::NotifyThroughputTrackerResults(CustomTrackerResults results) {
void ProxyImpl::NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) {
DCHECK(IsImplThread());
MainThreadTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&ProxyMain::NotifyThroughputTrackerResults,
proxy_main_weak_ptr_, std::move(results)));
FROM_HERE,
base::BindOnce(&ProxyMain::NotifyCompositorMetricsTrackerResults,
proxy_main_weak_ptr_, std::move(results)));
}
void ProxyImpl::DidObserveFirstScrollDelay(

@ -145,7 +145,8 @@ class CC_EXPORT ProxyImpl : public LayerTreeHostImplClient,
ElementListType element_list_type) override;
void NotifyPaintWorkletStateChange(
Scheduler::PaintWorkletState state) override;
void NotifyThroughputTrackerResults(CustomTrackerResults results) override;
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override;
void DidObserveFirstScrollDelay(
int source_frame_number,
base::TimeDelta first_scroll_delay,

@ -509,8 +509,9 @@ void ProxyMain::DidPresentCompositorFrame(
std::move(sucessful_presentation_callbacks), frame_timing_details);
}
void ProxyMain::NotifyThroughputTrackerResults(CustomTrackerResults results) {
layer_tree_host_->NotifyThroughputTrackerResults(std::move(results));
void ProxyMain::NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) {
layer_tree_host_->NotifyCompositorMetricsTrackerResults(std::move(results));
}
void ProxyMain::DidObserveFirstScrollDelay(

@ -69,7 +69,7 @@ class CC_EXPORT ProxyMain : public Proxy {
std::vector<PresentationTimeCallbackBuffer::SuccessfulCallbackWithDetails>
successful_presentation_callbacks,
const viz::FrameTimingDetails& frame_timing_details);
void NotifyThroughputTrackerResults(CustomTrackerResults results);
void NotifyCompositorMetricsTrackerResults(CustomTrackerResults results);
void DidObserveFirstScrollDelay(int source_frame_number,
base::TimeDelta first_scroll_delay,
base::TimeTicks first_scroll_timestamp);

@ -717,7 +717,7 @@ void SingleThreadProxy::NotifyPaintWorkletStateChange(
NOTREACHED();
}
void SingleThreadProxy::NotifyThroughputTrackerResults(
void SingleThreadProxy::NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) {
DCHECK(!task_runner_provider_->HasImplThread() ||
task_runner_provider_->IsImplThread());
@ -726,7 +726,7 @@ void SingleThreadProxy::NotifyThroughputTrackerResults(
// destruction. Regardless, `layer_tree_host_` should be accessed from
// MainThread side.
DebugScopedSetMainThread main(task_runner_provider_);
layer_tree_host_->NotifyThroughputTrackerResults(std::move(results));
layer_tree_host_->NotifyCompositorMetricsTrackerResults(std::move(results));
}
bool SingleThreadProxy::IsInSynchronousComposite() const {

@ -161,7 +161,8 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
ElementListType element_list_type) override;
void NotifyPaintWorkletStateChange(
Scheduler::PaintWorkletState state) override;
void NotifyThroughputTrackerResults(CustomTrackerResults results) override;
void NotifyCompositorMetricsTrackerResults(
CustomTrackerResults results) override;
bool IsInSynchronousComposite() const override;
void FrameSinksToThrottleUpdated(
const base::flat_set<viz::FrameSinkId>& ids) override;

@ -952,7 +952,7 @@ void LayerContextImpl::NotifyAnimationWorkletStateChange(
void LayerContextImpl::NotifyPaintWorkletStateChange(
cc::Scheduler::PaintWorkletState state) {}
void LayerContextImpl::NotifyThroughputTrackerResults(
void LayerContextImpl::NotifyCompositorMetricsTrackerResults(
cc::CustomTrackerResults results) {}
bool LayerContextImpl::IsInSynchronousComposite() const {

@ -88,7 +88,7 @@ class LayerContextImpl : public cc::LayerTreeHostImplClient,
cc::ElementListType element_list_type) override;
void NotifyPaintWorkletStateChange(
cc::Scheduler::PaintWorkletState state) override;
void NotifyThroughputTrackerResults(
void NotifyCompositorMetricsTrackerResults(
cc::CustomTrackerResults results) override;
bool IsInSynchronousComposite() const override;
void FrameSinksToThrottleUpdated(

@ -482,7 +482,7 @@ LayerTreeView::GetBeginMainFrameMetrics() {
return delegate_->GetBeginMainFrameMetrics();
}
void LayerTreeView::NotifyThroughputTrackerResults(
void LayerTreeView::NotifyCompositorMetricsTrackerResults(
cc::CustomTrackerResults results) {
NOTREACHED();
}

@ -116,7 +116,7 @@ class PLATFORM_EXPORT LayerTreeView
cc::ActiveFrameSequenceTrackers trackers) override;
std::unique_ptr<cc::BeginMainFrameMetrics> GetBeginMainFrameMetrics()
override;
void NotifyThroughputTrackerResults(
void NotifyCompositorMetricsTrackerResults(
cc::CustomTrackerResults results) override;
void DidObserveFirstScrollDelay(
int source_frame_number,

@ -809,7 +809,7 @@ Compositor::GetBeginMainFrameMetrics() {
#endif
}
void Compositor::NotifyThroughputTrackerResults(
void Compositor::NotifyCompositorMetricsTrackerResults(
cc::CustomTrackerResults results) {
for (auto& pair : results)
ReportMetricsForTracker(pair.first, std::move(pair.second));
@ -872,7 +872,7 @@ void Compositor::StartMetricsTracker(
auto& tracker_state = compositor_metrics_tracker_map_[tracker_id];
tracker_state.report_callback = std::move(callback);
animation_host_->StartThroughputTracking(tracker_id);
animation_host_->StartCompositorMetricsTracking(tracker_id);
}
bool Compositor::StopMetricsTracker(TrackerId tracker_id) {
@ -887,7 +887,7 @@ bool Compositor::StopMetricsTracker(TrackerId tracker_id) {
}
it->second.should_report = true;
animation_host_->StopThroughputTracking(tracker_id);
animation_host_->StopCompositorMetricsTracking(tracker_id);
return true;
}
@ -900,7 +900,7 @@ void Compositor::CancelMetricsTracker(TrackerId tracker_id) {
compositor_metrics_tracker_map_.erase(it);
if (should_stop)
animation_host_->StopThroughputTracking(tracker_id);
animation_host_->StopCompositorMetricsTracking(tracker_id);
}
void Compositor::OnResume() {

@ -427,7 +427,7 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
cc::ActiveFrameSequenceTrackers trackers) override {}
std::unique_ptr<cc::BeginMainFrameMetrics> GetBeginMainFrameMetrics()
override;
void NotifyThroughputTrackerResults(
void NotifyCompositorMetricsTrackerResults(
cc::CustomTrackerResults results) override;
void DidObserveFirstScrollDelay(
int source_frame_number,