Skip to content

Commit

Permalink
Report event latency in LayerTreeHostImpl
Browse files Browse the repository at this point in the history
Directly report event latency in LayerTreeHostImpl instead of
plumbing to ui::Compositor.

BUG=b:249557153

Change-Id: Iaa9c4efd587e8c7f46d00d2ace97fddc778216ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3991978
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Mohsen Izadi <mohsen@chromium.org>
Reviewed-by: Jonathan Ross <jonross@chromium.org>
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Yichen Zhou <yichenz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1070032}
  • Loading branch information
Yichen authored and Chromium LUCI CQ committed Nov 10, 2022
1 parent 477a684 commit d2652ff
Show file tree
Hide file tree
Showing 21 changed files with 4 additions and 73 deletions.
1 change: 1 addition & 0 deletions ash/metrics/ui_metrics_recorder.cc
Expand Up @@ -107,6 +107,7 @@ void UiMetricsRecorder::ReportPercentDroppedFramesInOneSecondWindow(

void UiMetricsRecorder::ReportEventLatency(
std::vector<cc::EventLatencyTracker::LatencyData> latencies) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
for (auto& latency : latencies) {
base::UmaHistogramCustomMicrosecondsTimes(
base::StrCat({"Ash.EventLatency.",
Expand Down
4 changes: 0 additions & 4 deletions cc/test/fake_layer_tree_host_impl_client.h
Expand Up @@ -5,8 +5,6 @@
#ifndef CC_TEST_FAKE_LAYER_TREE_HOST_IMPL_CLIENT_H_
#define CC_TEST_FAKE_LAYER_TREE_HOST_IMPL_CLIENT_H_

#include <vector>

#include "cc/trees/layer_tree_host_impl.h"
#include "components/viz/common/frame_sinks/begin_frame_args.h"

Expand Down Expand Up @@ -62,8 +60,6 @@ class FakeLayerTreeHostImplClient : public LayerTreeHostImplClient {
const base::flat_set<viz::FrameSinkId>& ids) override {}
void ClearHistory() override {}
size_t CommitDurationSampleCountForTesting() const override;
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) override {}

void reset_did_request_impl_side_invalidation() {
did_request_impl_side_invalidation_ = false;
Expand Down
3 changes: 0 additions & 3 deletions cc/test/layer_tree_test.cc
Expand Up @@ -493,9 +493,6 @@ class LayerTreeHostClientForTesting : public LayerTreeHostClient,
uint32_t frame_token,
const gfx::PresentationFeedback& feedback) override {}

void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) override {}

private:
explicit LayerTreeHostClientForTesting(TestHooks* test_hooks)
: test_hooks_(test_hooks) {}
Expand Down
2 changes: 0 additions & 2 deletions cc/test/stub_layer_tree_host_client.h
Expand Up @@ -58,8 +58,6 @@ class StubLayerTreeHostClient : public LayerTreeHostClient {
void DidPresentCompositorFrame(
uint32_t frame_token,
const gfx::PresentationFeedback& feedback) override {}
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) override {}
};

} // namespace cc
Expand Down
5 changes: 0 additions & 5 deletions cc/trees/layer_tree_host.cc
Expand Up @@ -1162,11 +1162,6 @@ void LayerTreeHost::NotifyThroughputTrackerResults(
client_->NotifyThroughputTrackerResults(std::move(results));
}

void LayerTreeHost::ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) {
client_->ReportEventLatency(std::move(latencies));
}

const base::WeakPtr<CompositorDelegateForInput>&
LayerTreeHost::GetDelegateForInput() const {
DCHECK(IsMainThread());
Expand Down
2 changes: 0 additions & 2 deletions cc/trees/layer_tree_host.h
Expand Up @@ -757,8 +757,6 @@ class CC_EXPORT LayerTreeHost : public MutatorHostClient {
void NotifyThroughputTrackerResults(CustomTrackerResults results);
void NotifyTransitionRequestsFinished(
const std::vector<uint32_t>& sequence_ids);
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies);

LayerTreeHostClient* client() {
DCHECK(IsMainThread());
Expand Down
4 changes: 0 additions & 4 deletions cc/trees/layer_tree_host_client.h
Expand Up @@ -6,11 +6,9 @@
#define CC_TREES_LAYER_TREE_HOST_CLIENT_H_

#include <memory>
#include <vector>

#include "base/time/time.h"
#include "cc/input/browser_controls_state.h"
#include "cc/metrics/event_latency_tracker.h"
#include "cc/metrics/frame_sequence_tracker_collection.h"
#include "cc/trees/paint_holding_commit_trigger.h"
#include "cc/trees/paint_holding_reason.h"
Expand Down Expand Up @@ -197,8 +195,6 @@ class LayerTreeHostClient {
// RecordEndOfFrameMetrics.
virtual std::unique_ptr<BeginMainFrameMetrics> GetBeginMainFrameMetrics() = 0;
virtual void NotifyThroughputTrackerResults(CustomTrackerResults results) = 0;
virtual void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) = 0;

// Should only be implemented by Blink.
virtual std::unique_ptr<WebVitalMetrics> GetWebVitalMetrics() = 0;
Expand Down
4 changes: 3 additions & 1 deletion cc/trees/layer_tree_host_impl.cc
Expand Up @@ -56,6 +56,7 @@
#include "cc/layers/surface_layer_impl.h"
#include "cc/layers/viewport.h"
#include "cc/metrics/compositor_frame_reporting_controller.h"
#include "cc/metrics/custom_metrics_recorder.h"
#include "cc/metrics/frame_sequence_metrics.h"
#include "cc/metrics/lcd_text_metrics_reporter.h"
#include "cc/metrics/ukm_smoothness_data.h"
Expand Down Expand Up @@ -2287,7 +2288,8 @@ void LayerTreeHostImpl::OnCompositorFrameTransitionDirectiveProcessed(

void LayerTreeHostImpl::ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) {
client_->ReportEventLatency(std::move(latencies));
if (auto* recorder = CustomMetricRecorder::Get())
recorder->ReportEventLatency(std::move(latencies));
}

void LayerTreeHostImpl::OnCanDrawStateChangedForTree() {
Expand Down
3 changes: 0 additions & 3 deletions cc/trees/layer_tree_host_impl.h
Expand Up @@ -184,9 +184,6 @@ class LayerTreeHostImplClient {

virtual size_t CommitDurationSampleCountForTesting() const = 0;

virtual void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) = 0;

protected:
virtual ~LayerTreeHostImplClient() = default;
};
Expand Down
2 changes: 0 additions & 2 deletions cc/trees/layer_tree_host_impl_unittest.cc
Expand Up @@ -284,8 +284,6 @@ class LayerTreeHostImplTest : public testing::Test,
void NotifyPaintWorkletStateChange(
Scheduler::PaintWorkletState state) override {}
void NotifyThroughputTrackerResults(CustomTrackerResults results) override {}
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) override {}

void DidObserveFirstScrollDelay(
base::TimeDelta first_scroll_delay,
Expand Down
8 changes: 0 additions & 8 deletions cc/trees/proxy_impl.cc
Expand Up @@ -322,14 +322,6 @@ void ProxyImpl::FrameSinksToThrottleUpdated(
NOTREACHED();
}

void ProxyImpl::ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) {
DCHECK(IsImplThread());
MainThreadTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&ProxyMain::ReportEventLatency,
proxy_main_weak_ptr_, std::move(latencies)));
}

void ProxyImpl::NotifyReadyToCommitOnImpl(
CompletionEvent* completion_event,
std::unique_ptr<CommitState> commit_state,
Expand Down
2 changes: 0 additions & 2 deletions cc/trees/proxy_impl.h
Expand Up @@ -137,8 +137,6 @@ class CC_EXPORT ProxyImpl : public LayerTreeHostImplClient,
bool IsInSynchronousComposite() const override;
void FrameSinksToThrottleUpdated(
const base::flat_set<viz::FrameSinkId>& id) override;
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) override;

// SchedulerClient implementation
bool WillBeginImplFrame(const viz::BeginFrameArgs& args) override;
Expand Down
5 changes: 0 additions & 5 deletions cc/trees/proxy_main.cc
Expand Up @@ -489,11 +489,6 @@ void ProxyMain::DidObserveFirstScrollDelay(
first_scroll_timestamp);
}

void ProxyMain::ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) {
layer_tree_host_->ReportEventLatency(std::move(latencies));
}

void ProxyMain::NotifyTransitionRequestFinished(uint32_t sequence_id) {
layer_tree_host_->NotifyTransitionRequestsFinished({sequence_id});
}
Expand Down
3 changes: 0 additions & 3 deletions cc/trees/proxy_main.h
Expand Up @@ -12,7 +12,6 @@
#include "base/time/time.h"
#include "cc/cc_export.h"
#include "cc/input/browser_controls_state.h"
#include "cc/metrics/event_latency_tracker.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/paint_holding_reason.h"
#include "cc/trees/proxy.h"
Expand Down Expand Up @@ -75,8 +74,6 @@ class CC_EXPORT ProxyMain : public Proxy {
void NotifyThroughputTrackerResults(CustomTrackerResults results);
void DidObserveFirstScrollDelay(base::TimeDelta first_scroll_delay,
base::TimeTicks first_scroll_timestamp);
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies);
void NotifyTransitionRequestFinished(uint32_t sequence_id);

CommitPipelineStage max_requested_pipeline_stage() const {
Expand Down
8 changes: 0 additions & 8 deletions cc/trees/single_thread_proxy.cc
Expand Up @@ -921,14 +921,6 @@ size_t SingleThreadProxy::CommitDurationSampleCountForTesting() const {
->CommitDurationSampleCountForTesting(); // IN-TEST
}

void SingleThreadProxy::ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) {
DCHECK(!task_runner_provider_->HasImplThread() ||
task_runner_provider_->IsImplThread());
DebugScopedSetMainThread main(task_runner_provider_);
layer_tree_host_->ReportEventLatency(std::move(latencies));
}

void SingleThreadProxy::SetRenderFrameObserver(
std::unique_ptr<RenderFrameMetadataObserver> observer) {
DCHECK(task_runner_provider_->IsMainThread());
Expand Down
2 changes: 0 additions & 2 deletions cc/trees/single_thread_proxy.h
Expand Up @@ -149,8 +149,6 @@ class CC_EXPORT SingleThreadProxy : public Proxy,
const base::flat_set<viz::FrameSinkId>& ids) override;
void ClearHistory() override;
size_t CommitDurationSampleCountForTesting() const override;
void ReportEventLatency(
std::vector<EventLatencyTracker::LatencyData> latencies) override;

void RequestNewLayerTreeFrameSink();

Expand Down
2 changes: 0 additions & 2 deletions content/browser/renderer_host/compositor_impl_android.h
Expand Up @@ -171,8 +171,6 @@ class CONTENT_EXPORT CompositorImpl
void DidObserveFirstScrollDelay(
base::TimeDelta first_scroll_delay,
base::TimeTicks first_scroll_timestamp) override {}
void ReportEventLatency(
std::vector<cc::EventLatencyTracker::LatencyData> latencies) override {}

// LayerTreeHostSingleThreadClient implementation.
void DidSubmitCompositorFrame() override;
Expand Down
Expand Up @@ -392,13 +392,6 @@ void LayerTreeView::RunPaintBenchmark(int repeat_count,
delegate_->RunPaintBenchmark(repeat_count, result);
}

void LayerTreeView::ReportEventLatency(
std::vector<cc::EventLatencyTracker::LatencyData> latencies) {
// EventLatency metrics for the renderers are reported in
// `CompositorFrameReporter`, so this functions should not be called.
NOTREACHED();
}

void LayerTreeView::DidRunBeginMainFrame() {
if (!delegate_)
return;
Expand Down
Expand Up @@ -110,8 +110,6 @@ class PLATFORM_EXPORT LayerTreeView
base::TimeTicks first_scroll_timestamp) override;
void RunPaintBenchmark(int repeat_count,
cc::PaintBenchmarkResult& result) override;
void ReportEventLatency(
std::vector<cc::EventLatencyTracker::LatencyData> latencies) override;

// cc::LayerTreeHostSingleThreadClient implementation.
void DidSubmitCompositorFrame() override;
Expand Down
6 changes: 0 additions & 6 deletions ui/compositor/compositor.cc
Expand Up @@ -767,12 +767,6 @@ void Compositor::NotifyThroughputTrackerResults(
ReportMetricsForTracker(pair.first, std::move(pair.second));
}

void Compositor::ReportEventLatency(
std::vector<cc::EventLatencyTracker::LatencyData> latencies) {
if (auto* recorder = cc::CustomMetricRecorder::Get())
recorder->ReportEventLatency(std::move(latencies));
}

void Compositor::DidReceiveCompositorFrameAck() {
++activated_frame_count_;
for (auto& observer : observer_list_)
Expand Down
2 changes: 0 additions & 2 deletions ui/compositor/compositor.h
Expand Up @@ -405,8 +405,6 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
void DidObserveFirstScrollDelay(
base::TimeDelta first_scroll_delay,
base::TimeTicks first_scroll_timestamp) override {}
void ReportEventLatency(
std::vector<cc::EventLatencyTracker::LatencyData> latencies) override;

// cc::LayerTreeHostSingleThreadClient implementation.
void DidSubmitCompositorFrame() override;
Expand Down

0 comments on commit d2652ff

Please sign in to comment.