[Part 1] 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. This CL also updates other related classes and references to ThroughputTracker in ui/compositor and ash/. Future CLs will update further references in /cc. Bug: b:380318532 Change-Id: I2db57102aa86b4ca083415688b8a8851d3144336 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6040362 Commit-Queue: Zoraiz Naeem <zoraiznaeem@chromium.org> Reviewed-by: Elly FJ <ellyjones@chromium.org> Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Cr-Commit-Position: refs/heads/main@{#1387186}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
152e93a8e2
commit
252b1315a4
ash
ambient
app_list
glanceables
common
glanceables_unittest.ccpublic
cpp
external_arc
message_center
shelf
system
holding_space
notification_center
privacy
tray
video_conference
wm
chrome/browser
ui
compositor
BUILD.gnanimation_throughput_reporter.ccanimation_throughput_reporter.hanimation_throughput_reporter_unittest.cccompositor.cccompositor.hcompositor_metrics_tracker.cccompositor_metrics_tracker.hcompositor_metrics_tracker_host.hcompositor_metrics_tracker_unittest.cccompositor_unittest.cc
test
compositor_metrics_report_checker.cccompositor_metrics_report_checker.hcompositor_metrics_reporter_test_base.cccompositor_metrics_reporter_test_base.h
throughput_tracker_host.htotal_animation_throughput_reporter.cctotal_animation_throughput_reporter.htotal_animation_throughput_reporter_unittest.ccviews
@ -425,7 +425,7 @@ void AmbientAnimationView::RestartThroughputTracking() {
|
||||
DCHECK(widget);
|
||||
ui::Compositor* compositor = widget->GetCompositor();
|
||||
DCHECK(compositor);
|
||||
throughput_tracker_ = compositor->RequestNewThroughputTracker();
|
||||
throughput_tracker_ = compositor->RequestNewCompositorMetricsTracker();
|
||||
throughput_tracker_->Start(
|
||||
base::BindOnce(&OnCompositorThroughputReported,
|
||||
/*logging_start_time=*/base::TimeTicks::Now(),
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "base/scoped_observation.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/lottie/animation.h"
|
||||
#include "ui/lottie/animation_observer.h"
|
||||
#include "ui/views/view.h"
|
||||
|
@ -2031,7 +2031,7 @@ void AppListControllerImpl::StartTrackingAnimationSmoothness(
|
||||
int64_t display_id) {
|
||||
auto* root_window = Shell::GetRootWindowForDisplayId(display_id);
|
||||
auto* compositor = root_window->layer()->GetCompositor();
|
||||
smoothness_tracker_ = compositor->RequestNewThroughputTracker();
|
||||
smoothness_tracker_ = compositor->RequestNewCompositorMetricsTracker();
|
||||
smoothness_tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating([](int smoothness) {
|
||||
UMA_HISTOGRAM_PERCENTAGE(kHomescreenAnimationHistogram, smoothness);
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "components/prefs/pref_member.h"
|
||||
#include "ui/aura/window_observer.h"
|
||||
#include "ui/base/mojom/menu_source_type.mojom-forward.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/display/display_observer.h"
|
||||
#include "ui/display/manager/display_manager_observer.h"
|
||||
#include "ui/display/types/display_constants.h"
|
||||
|
@ -820,7 +820,7 @@ void AppListFolderView::ConfigureForFolderItemView(
|
||||
void AppListFolderView::ScheduleShowHideAnimation(bool show,
|
||||
bool hide_for_reparent) {
|
||||
show_hide_metrics_tracker_ =
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker();
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
show_hide_metrics_tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating([](int smoothness) {
|
||||
UMA_HISTOGRAM_PERCENTAGE(
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/views/controls/button/button.h"
|
||||
#include "ui/views/view.h"
|
||||
|
||||
|
@ -1398,7 +1398,7 @@ void AppsGridView::CalculateIdealBounds() {
|
||||
void AppsGridView::AnimateToIdealBounds(bool is_animating_top_to_bottom) {
|
||||
if (layer()->GetCompositor()) {
|
||||
item_reorder_animation_tracker_ =
|
||||
layer()->GetCompositor()->RequestNewThroughputTracker();
|
||||
layer()->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
item_reorder_animation_tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating(
|
||||
&ReportItemDragReorderAnimationSmoothness, IsTabletMode())));
|
||||
@ -2194,7 +2194,7 @@ views::AnimationBuilder AppsGridView::FadeOutVisibleItemsForReorder(
|
||||
|
||||
grid_animation_status_ = AppListGridAnimationStatus::kReorderFadeOut;
|
||||
reorder_animation_tracker_.emplace(
|
||||
layer()->GetCompositor()->RequestNewThroughputTracker());
|
||||
layer()->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
reorder_animation_tracker_->Start(metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&ReportReorderAnimationSmoothness, IsTabletMode())));
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include "base/time/time.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer_tree_owner.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/events/keycodes/keyboard_codes_posix.h"
|
||||
#include "ui/views/animation/animation_abort_handle.h"
|
||||
#include "ui/views/view.h"
|
||||
|
@ -571,7 +571,7 @@ void PagedAppsGridView::TransitionStarted() {
|
||||
}
|
||||
|
||||
pagination_metrics_tracker_ =
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker();
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
pagination_metrics_tracker_->Start(metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&ReportPaginationSmoothness)));
|
||||
}
|
||||
|
@ -17,8 +17,8 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/time/time.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/presentation_time_recorder.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/events/types/event_type.h"
|
||||
#include "ui/gfx/geometry/point_f.h"
|
||||
#include "ui/views/animation/animation_abort_handle.h"
|
||||
|
@ -438,7 +438,7 @@ void GlanceablesTimeManagementBubbleView::SetUpResizeThroughputTracker(
|
||||
}
|
||||
|
||||
resize_throughput_tracker_.emplace(
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker());
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
resize_throughput_tracker_->Start(
|
||||
ash::metrics_util::ForSmoothnessV3(base::BindRepeating(
|
||||
[](const std::string& histogram_name, int smoothness) {
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "ash/style/error_message_toast.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "ui/base/models/combobox_model.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/views/controls/button/button.h"
|
||||
#include "ui/views/layout/flex_layout_view.h"
|
||||
#include "ui/views/view.h"
|
||||
|
@ -59,7 +59,7 @@ class ResizeAnimationWaiter {
|
||||
// Force frames and wait for all throughput trackers to be gone to allow
|
||||
// animation throughput data to be passed from cc to ui.
|
||||
ui::Compositor* compositor = bubble_view_->GetWidget()->GetCompositor();
|
||||
while (compositor->has_throughput_trackers_for_testing()) {
|
||||
while (compositor->has_compositor_metrics_trackers_for_testing()) {
|
||||
compositor->ScheduleFullRedraw();
|
||||
std::ignore = ui::WaitForNextFrameToBePresented(compositor,
|
||||
base::Milliseconds(500));
|
||||
|
@ -445,7 +445,7 @@ class ArcNotificationViewRenderByChromeEnabledTest
|
||||
|
||||
// Force frames and wait for all throughput trackers to be gone to allow
|
||||
// animation throughput data to be passed from cc to ui.
|
||||
while (compositor->has_throughput_trackers_for_testing()) {
|
||||
while (compositor->has_compositor_metrics_trackers_for_testing()) {
|
||||
compositor->ScheduleFullRedraw();
|
||||
std::ignore = ui::WaitForNextFrameToBePresented(compositor,
|
||||
base::Milliseconds(500));
|
||||
|
@ -127,7 +127,7 @@ class DragWindowFromShelfControllerTest : public AshTestBase {
|
||||
|
||||
// Force frames and wait for all throughput trackers to be gone to allow
|
||||
// animation throughput data to be passed from cc to ui.
|
||||
while (compositor->has_throughput_trackers_for_testing()) {
|
||||
while (compositor->has_compositor_metrics_trackers_for_testing()) {
|
||||
compositor->ScheduleFullRedraw();
|
||||
std::ignore = ui::WaitForNextFrameToBePresented(compositor,
|
||||
base::Milliseconds(500));
|
||||
|
@ -26,13 +26,13 @@
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/compositor/animation_throughput_reporter.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animation_observer.h"
|
||||
#include "ui/compositor/layer_delegate.h"
|
||||
#include "ui/compositor/paint_recorder.h"
|
||||
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
|
||||
#include "ui/compositor/scoped_layer_animation_settings.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/gfx/canvas.h"
|
||||
#include "ui/gfx/geometry/rounded_corners_f.h"
|
||||
#include "ui/gfx/geometry/transform_util.h"
|
||||
@ -124,8 +124,9 @@ class BoundsAnimationReporter : public gfx::AnimationDelegate {
|
||||
public:
|
||||
BoundsAnimationReporter(views::View* view,
|
||||
metrics_util::ReportCallback report_callback)
|
||||
: tracker_(
|
||||
view->GetWidget()->GetCompositor()->RequestNewThroughputTracker()) {
|
||||
: tracker_(view->GetWidget()
|
||||
->GetCompositor()
|
||||
->RequestNewCompositorMetricsTracker()) {
|
||||
tracker_.Start(std::move(report_callback));
|
||||
}
|
||||
BoundsAnimationReporter(const BoundsAnimationReporter& other) = delete;
|
||||
|
@ -1505,7 +1505,7 @@ void ShelfView::AnimateToIdealBounds() {
|
||||
CalculateIdealBounds();
|
||||
|
||||
move_animation_tracker_.emplace(
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker());
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
move_animation_tracker_->Start(metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&ReportMoveAnimationSmoothness)));
|
||||
|
||||
@ -2364,7 +2364,7 @@ void ShelfView::ShelfItemRemoved(int model_index, const ShelfItem& old_item) {
|
||||
// tracking for the first one.
|
||||
if (!fade_out_animation_tracker_) {
|
||||
fade_out_animation_tracker_.emplace(
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker());
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
fade_out_animation_tracker_->Start(metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&ReportFadeOutAnimationSmoothness)));
|
||||
}
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/base/mojom/menu_source_type.mojom-forward.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer_tree_owner.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/views/accessibility/view_accessibility.h"
|
||||
#include "ui/views/accessible_pane_view.h"
|
||||
#include "ui/views/animation/bounds_animator_observer.h"
|
||||
|
@ -275,7 +275,7 @@ class HoldingSpaceTrayBubble::ChildBubbleContainer
|
||||
kAnimationDuration);
|
||||
layout_animation_->SetTweenType(gfx::Tween::Type::FAST_OUT_SLOW_IN);
|
||||
layout_animation_throughput_tracker_ =
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker();
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
layout_animation_throughput_tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating(
|
||||
holding_space_metrics::RecordBubbleResizeAnimationSmoothness)));
|
||||
|
@ -80,7 +80,9 @@ class HoldingSpaceTrayIcon::ResizeAnimation
|
||||
target_size_(target_size),
|
||||
animation_(this),
|
||||
animation_throughput_tracker_(
|
||||
icon->GetWidget()->GetCompositor()->RequestNewThroughputTracker()) {
|
||||
icon->GetWidget()
|
||||
->GetCompositor()
|
||||
->RequestNewCompositorMetricsTracker()) {
|
||||
animation_.SetTweenType(gfx::Tween::FAST_OUT_SLOW_IN);
|
||||
animation_.SetSlideDuration(
|
||||
ui::ScopedAnimationDurationScaleMode::duration_multiplier() *
|
||||
|
@ -436,7 +436,7 @@ void AshMessagePopupCollection::AnimationStarted() {
|
||||
// this when the first popup shows in the animation sequence.
|
||||
animation_tracker_.emplace(last_pop_up_added_->GetWidget()
|
||||
->GetCompositor()
|
||||
->RequestNewThroughputTracker());
|
||||
->RequestNewCompositorMetricsTracker());
|
||||
animation_tracker_->Start(metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&ReportPopupAnimationSmoothness)));
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define ASH_SYSTEM_NOTIFICATION_CENTER_ASH_MESSAGE_POPUP_COLLECTION_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
@ -15,7 +16,7 @@
|
||||
#include "ash/system/tray/tray_event_filter.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/display/display_observer.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/message_center/views/message_popup_collection.h"
|
||||
|
@ -355,7 +355,7 @@ class AshNotificationViewTestBase : public AshTestBase,
|
||||
|
||||
// Force frames and wait for all throughput trackers to be gone to allow
|
||||
// animation throughput data to be passed from cc to ui.
|
||||
while (compositor->has_throughput_trackers_for_testing()) {
|
||||
while (compositor->has_compositor_metrics_trackers_for_testing()) {
|
||||
compositor->ScheduleFullRedraw();
|
||||
std::ignore = ui::WaitForNextFrameToBePresented(compositor,
|
||||
base::Milliseconds(500));
|
||||
|
@ -81,7 +81,8 @@ void SetupThroughputTrackerForAnimationSmoothness(
|
||||
return;
|
||||
}
|
||||
|
||||
tracker.emplace(widget->GetCompositor()->RequestNewThroughputTracker());
|
||||
tracker.emplace(
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
tracker->Start(ash::metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&RecordAnimationSmoothness, histogram_name)));
|
||||
}
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/scoped_multi_source_observation.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/message_center/message_center.h"
|
||||
#include "ui/message_center/message_center_observer.h"
|
||||
#include "ui/message_center/notification_view_controller.h"
|
||||
|
@ -80,7 +80,8 @@ void StartRecordAnimationSmoothness(
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
tracker.emplace(widget->GetCompositor()->RequestNewThroughputTracker());
|
||||
tracker.emplace(
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
tracker->Start(ash::metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating([](int smoothness) {
|
||||
base::UmaHistogramPercentage(
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "base/time/time.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
|
||||
namespace gfx {
|
||||
class LinearAnimation;
|
||||
|
@ -16,10 +16,10 @@
|
||||
#include "ui/accessibility/ax_node_data.h"
|
||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/gfx/animation/slide_animation.h"
|
||||
#include "ui/views/accessibility/view_accessibility.h"
|
||||
#include "ui/views/controls/image_view.h"
|
||||
@ -59,7 +59,8 @@ void SetupThroughputTrackerForAnimationSmoothness(
|
||||
if (tracker || !widget)
|
||||
return;
|
||||
|
||||
tracker.emplace(widget->GetCompositor()->RequestNewThroughputTracker());
|
||||
tracker.emplace(
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
tracker->Start(ash::metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&RecordAnimationSmoothness, histogram_name)));
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "base/callback_list.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/views/animation/animation_delegate_views.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/view.h"
|
||||
|
@ -118,7 +118,7 @@ class TrayItemViewTest : public AshTestBase {
|
||||
// animation throughput data to be passed from cc to ui.
|
||||
ui::Compositor* const compositor =
|
||||
tray_item()->GetWidget()->GetCompositor();
|
||||
while (compositor->has_throughput_trackers_for_testing()) {
|
||||
while (compositor->has_compositor_metrics_trackers_for_testing()) {
|
||||
compositor->ScheduleFullRedraw();
|
||||
std::ignore = ui::WaitForNextFrameToBePresented(compositor,
|
||||
base::Milliseconds(500));
|
||||
|
@ -30,9 +30,9 @@
|
||||
#include "ui/chromeos/styles/cros_tokens_color_mappings.h"
|
||||
#include "ui/compositor/animation_throughput_reporter.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/scoped_animation_duration_scale_mode.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/gfx/animation/linear_animation.h"
|
||||
#include "ui/gfx/animation/tween.h"
|
||||
#include "ui/gfx/canvas.h"
|
||||
@ -77,7 +77,8 @@ void StartRecordAnimationSmoothness(
|
||||
return;
|
||||
}
|
||||
|
||||
tracker.emplace(widget->GetCompositor()->RequestNewThroughputTracker());
|
||||
tracker.emplace(
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
tracker->Start(ash::metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating([](int smoothness) {
|
||||
base::UmaHistogramPercentage(
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "chromeos/crosapi/mojom/video_conference.mojom-forward.h"
|
||||
#include "ui/base/metadata/metadata_header_macros.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "ui/views/animation/animation_delegate_views.h"
|
||||
#include "ui/views/layout/flex_layout_view.h"
|
||||
|
@ -45,7 +45,7 @@ void DeskAnimationBase::Launch() {
|
||||
// Request a new sequence tracker so the tracking number can't be reused.
|
||||
throughput_tracker_ =
|
||||
desks_util::GetSelectedCompositorForPerformanceMetrics()
|
||||
->RequestNewThroughputTracker();
|
||||
->RequestNewCompositorMetricsTracker();
|
||||
throughput_tracker_->Start(GetSmoothnessReportCallback());
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "base/functional/callback.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/time/time.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
|
@ -224,7 +224,7 @@ bool DeskActivationAnimation::EndSwipeAnimation() {
|
||||
// Start tracking the animation smoothness after the continuous gesture swipe
|
||||
// has ended.
|
||||
throughput_tracker_ = desks_util::GetSelectedCompositorForPerformanceMetrics()
|
||||
->RequestNewThroughputTracker();
|
||||
->RequestNewCompositorMetricsTracker();
|
||||
throughput_tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating([](int smoothness) {
|
||||
UMA_HISTOGRAM_PERCENTAGE(kDeskEndGestureSmoothnessHistogramName,
|
||||
|
@ -100,11 +100,11 @@
|
||||
#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
|
||||
#include "ui/aura/client/aura_constants.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/compositor_observer.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/presentation_time_recorder.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/gfx/geometry/size_f.h"
|
||||
#include "ui/gfx/geometry/transform.h"
|
||||
@ -215,7 +215,7 @@ class OverviewMetricsTracker : public OverviewGrid::MetricsTracker {
|
||||
bool in_split_view,
|
||||
bool single_animation_in_clamshell,
|
||||
bool minimized_in_tablet)
|
||||
: tracker_(compositor->RequestNewThroughputTracker()) {
|
||||
: tracker_(compositor->RequestNewCompositorMetricsTracker()) {
|
||||
tracker_.Start(metrics_util::ForSmoothnessV3(base::BindRepeating(
|
||||
&OverviewMetricsTracker::ReportOverviewSmoothness, in_split_view,
|
||||
single_animation_in_clamshell, minimized_in_tablet)));
|
||||
|
@ -237,7 +237,7 @@ void OverviewTestBase::CheckOverviewEnterExitHistogram(
|
||||
// animation throughput data to be passed from cc to ui.
|
||||
ui::Compositor* compositor =
|
||||
Shell::GetPrimaryRootWindow()->layer()->GetCompositor();
|
||||
while (compositor->has_throughput_trackers_for_testing()) {
|
||||
while (compositor->has_compositor_metrics_trackers_for_testing()) {
|
||||
compositor->ScheduleFullRedraw();
|
||||
std::ignore =
|
||||
ui::WaitForNextFrameToBePresented(compositor, base::Milliseconds(500));
|
||||
|
@ -78,10 +78,10 @@
|
||||
#include "ui/aura/window_delegate.h"
|
||||
#include "ui/base/ime/ash/ime_bridge.h"
|
||||
#include "ui/base/ime/input_method.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/presentation_time_recorder.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/display/types/display_constants.h"
|
||||
#include "ui/gfx/animation/slide_animation.h"
|
||||
@ -278,7 +278,8 @@ class SplitViewController::DividerSnapAnimation
|
||||
std::make_unique<views::CompositorAnimationRunner>(widget, FROM_HERE));
|
||||
SetContainer(container);
|
||||
|
||||
tracker_.emplace(widget->GetCompositor()->RequestNewThroughputTracker());
|
||||
tracker_.emplace(
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating([](int smoothness) {
|
||||
UMA_HISTOGRAM_PERCENTAGE(kDividerAnimationSmoothness, smoothness);
|
||||
|
@ -850,7 +850,7 @@ void TabletModeController::OnLayerAnimationScheduled(
|
||||
|
||||
if (!transition_tracker_) {
|
||||
transition_tracker_ =
|
||||
animating_layer_->GetCompositor()->RequestNewThroughputTracker();
|
||||
animating_layer_->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
transition_tracker_->Start(metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&ReportTrasitionSmoothness,
|
||||
display::Screen::GetScreen()->GetTabletState() ==
|
||||
|
@ -24,11 +24,11 @@
|
||||
#include "base/timer/timer.h"
|
||||
#include "chromeos/dbus/power/power_manager_client.h"
|
||||
#include "ui/aura/window_occlusion_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer_animation_element.h"
|
||||
#include "ui/compositor/layer_animation_observer.h"
|
||||
#include "ui/compositor/layer_observer.h"
|
||||
#include "ui/compositor/layer_tree_owner.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/display/manager/display_manager_observer.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/devices/input_device_event_observer.h"
|
||||
|
@ -154,7 +154,7 @@ class CrossFadeObserver : public aura::WindowObserver,
|
||||
window_->AddObserver(this);
|
||||
|
||||
smoothness_tracker_ =
|
||||
layer_->GetCompositor()->RequestNewThroughputTracker();
|
||||
layer_->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
smoothness_tracker_->Start(
|
||||
metrics_util::ForSmoothnessV3(base::BindRepeating(
|
||||
[](const std::optional<std::string>& histogram_name,
|
||||
|
@ -245,10 +245,10 @@
|
||||
#include "ui/base/mojom/window_show_state.mojom.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker_host.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/throughput_tracker_host.h"
|
||||
#include "ui/display/display.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/event_constants.h"
|
||||
@ -955,7 +955,7 @@ class DisplaySmoothnessTracker {
|
||||
// Return true if tracking is started successfully.
|
||||
bool Start(int64_t display_id,
|
||||
base::TimeDelta throughput_interval,
|
||||
ui::ThroughputTrackerHost::ReportCallback callback) {
|
||||
ui::CompositorMetricsTrackerHost::ReportCallback callback) {
|
||||
auto* root_window = ash::Shell::GetRootWindowForDisplayId(display_id);
|
||||
if (!root_window) {
|
||||
return false;
|
||||
@ -966,19 +966,20 @@ class DisplaySmoothnessTracker {
|
||||
DCHECK(root_window_tracker_.windows().empty());
|
||||
root_window_tracker_.Add(root_window);
|
||||
|
||||
tracker_ =
|
||||
root_window->layer()->GetCompositor()->RequestNewThroughputTracker();
|
||||
tracker_ = root_window->layer()
|
||||
->GetCompositor()
|
||||
->RequestNewCompositorMetricsTracker();
|
||||
tracker_->Start(std::move(callback));
|
||||
|
||||
throughtput_timer_.Start(FROM_HERE, throughput_interval, this,
|
||||
&DisplaySmoothnessTracker::OnThroughputTimerFired);
|
||||
throughput_timer_.Start(FROM_HERE, throughput_interval, this,
|
||||
&DisplaySmoothnessTracker::OnThroughputTimerFired);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Stop(ReportCallback callback) {
|
||||
stopping_ = true;
|
||||
throughtput_timer_.Stop();
|
||||
throughput_timer_.Stop();
|
||||
callback_ = std::move(callback);
|
||||
return tracker_->Stop();
|
||||
}
|
||||
@ -1002,7 +1003,7 @@ class DisplaySmoothnessTracker {
|
||||
LOG(ERROR) << "Unable to collect throughput because underlying "
|
||||
"RootWindow is gone.";
|
||||
has_error_ = true;
|
||||
throughtput_timer_.Stop();
|
||||
throughput_timer_.Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1019,7 +1020,7 @@ class DisplaySmoothnessTracker {
|
||||
bool has_error_ = false;
|
||||
base::TimeTicks start_time_;
|
||||
|
||||
base::RepeatingTimer throughtput_timer_;
|
||||
base::RepeatingTimer throughput_timer_;
|
||||
std::vector<int> throughput_;
|
||||
};
|
||||
|
||||
|
@ -301,7 +301,7 @@
|
||||
#include "chrome/grit/chrome_unscaled_resources.h"
|
||||
#include "chromeos/ui/frame/caption_buttons/frame_size_button.h"
|
||||
#include "chromeos/ui/wm/desks/desks_helper.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#else
|
||||
#include "chrome/browser/ui/signin/signin_view_controller.h"
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
@ -1685,7 +1685,7 @@ void BrowserView::UpdateLoadingAnimations(bool is_visible) {
|
||||
if (should_animate) {
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
loading_animation_tracker_.emplace(
|
||||
GetWidget()->GetCompositor()->RequestNewThroughputTracker());
|
||||
GetWidget()->GetCompositor()->RequestNewCompositorMetricsTracker());
|
||||
loading_animation_tracker_->Start(ash::metrics_util::ForSmoothnessV3(
|
||||
base::BindRepeating(&RecordTabLoadingSmoothness)));
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@
|
||||
#include "ui/views/window/client_view.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#endif
|
||||
|
||||
// NOTE: For more information about the objects and files in this directory,
|
||||
|
@ -24,6 +24,9 @@ component("compositor") {
|
||||
"compositor_export.h",
|
||||
"compositor_lock.cc",
|
||||
"compositor_lock.h",
|
||||
"compositor_metrics_tracker.cc",
|
||||
"compositor_metrics_tracker.h",
|
||||
"compositor_metrics_tracker_host.h",
|
||||
"compositor_observer.h",
|
||||
"compositor_switches.cc",
|
||||
"compositor_switches.h",
|
||||
@ -71,9 +74,6 @@ component("compositor") {
|
||||
"scoped_animation_duration_scale_mode.h",
|
||||
"scoped_layer_animation_settings.cc",
|
||||
"scoped_layer_animation_settings.h",
|
||||
"throughput_tracker.cc",
|
||||
"throughput_tracker.h",
|
||||
"throughput_tracker_host.h",
|
||||
"total_animation_throughput_reporter.cc",
|
||||
"total_animation_throughput_reporter.h",
|
||||
"transform_animation_curve_adapter.cc",
|
||||
@ -125,10 +125,12 @@ component("compositor") {
|
||||
static_library("test_support") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"test/animation_throughput_reporter_test_base.cc",
|
||||
"test/animation_throughput_reporter_test_base.h",
|
||||
"test/begin_main_frame_waiter.cc",
|
||||
"test/begin_main_frame_waiter.h",
|
||||
"test/compositor_metrics_report_checker.cc",
|
||||
"test/compositor_metrics_report_checker.h",
|
||||
"test/compositor_metrics_reporter_test_base.cc",
|
||||
"test/compositor_metrics_reporter_test_base.h",
|
||||
"test/direct_layer_tree_frame_sink.cc",
|
||||
"test/direct_layer_tree_frame_sink.h",
|
||||
"test/draw_waiter_for_test.cc",
|
||||
@ -160,8 +162,6 @@ static_library("test_support") {
|
||||
"test/test_suite.h",
|
||||
"test/test_utils.cc",
|
||||
"test/test_utils.h",
|
||||
"test/throughput_report_checker.cc",
|
||||
"test/throughput_report_checker.h",
|
||||
]
|
||||
|
||||
if (is_android) {
|
||||
@ -229,6 +229,7 @@ test("compositor_unittests") {
|
||||
"callback_layer_animation_observer_unittest.cc",
|
||||
"canvas_painter_unittest.cc",
|
||||
"compositor_lock_unittest.cc",
|
||||
"compositor_metrics_tracker_unittest.cc",
|
||||
"compositor_unittest.cc",
|
||||
"layer_animation_element_unittest.cc",
|
||||
"layer_animation_sequence_unittest.cc",
|
||||
@ -237,7 +238,6 @@ test("compositor_unittests") {
|
||||
"layer_unittest.cc",
|
||||
"presentation_time_recorder_unittest.cc",
|
||||
"run_all_unittests.cc",
|
||||
"throughput_tracker_unittest.cc",
|
||||
"transform_animation_curve_adapter_unittest.cc",
|
||||
]
|
||||
|
||||
|
@ -17,11 +17,11 @@
|
||||
#include "cc/animation/animation.h"
|
||||
#include "ui/compositor/callback_layer_animation_observer.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animation_delegate.h"
|
||||
#include "ui/compositor/layer_animation_sequence.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@ -66,8 +66,9 @@ class AnimationThroughputReporter::AnimationTracker
|
||||
void OnAnimatorDetachedFromTimeline() override {
|
||||
// Gives up tracking when detached from the timeline.
|
||||
first_animation_group_id_.reset();
|
||||
if (throughput_tracker_)
|
||||
throughput_tracker_.reset();
|
||||
if (metrics_tracker_) {
|
||||
metrics_tracker_.reset();
|
||||
}
|
||||
|
||||
// OnAnimationEnded would not happen after detached from the timeline.
|
||||
// So do the clean up here.
|
||||
@ -117,24 +118,24 @@ class AnimationThroughputReporter::AnimationTracker
|
||||
|
||||
ui::Compositor* compositor =
|
||||
AnimationThroughputReporter::GetCompositor(animator_);
|
||||
throughput_tracker_ = compositor->RequestNewThroughputTracker();
|
||||
throughput_tracker_->Start(report_callback_);
|
||||
metrics_tracker_ = compositor->RequestNewCompositorMetricsTracker();
|
||||
metrics_tracker_->Start(report_callback_);
|
||||
}
|
||||
|
||||
// Invoked when all animation sequences finish.
|
||||
bool OnAnimationEnded(const CallbackLayerAnimationObserver& self) {
|
||||
// |throughput_tracker| could reset when detached from animation timeline.
|
||||
if (throughput_tracker_) {
|
||||
// `metrics_tracker_` could reset when detached from animation timeline.
|
||||
if (metrics_tracker_) {
|
||||
if (started_animations_aborted_)
|
||||
throughput_tracker_->Cancel();
|
||||
metrics_tracker_->Cancel();
|
||||
else
|
||||
throughput_tracker_->Stop();
|
||||
metrics_tracker_->Stop();
|
||||
|
||||
// `OnAnimationEnded` could be called multiple times when scheduling
|
||||
// animations. Destroy the tracker so that it is not stopped/canceled
|
||||
// more than once. New tracker will be created when new animation sequence
|
||||
// is started.
|
||||
throughput_tracker_.reset();
|
||||
metrics_tracker_.reset();
|
||||
}
|
||||
|
||||
first_animation_group_id_.reset();
|
||||
@ -147,7 +148,7 @@ class AnimationThroughputReporter::AnimationTracker
|
||||
|
||||
const raw_ptr<LayerAnimator, DanglingUntriaged> animator_;
|
||||
|
||||
std::optional<ThroughputTracker> throughput_tracker_;
|
||||
std::optional<CompositorMetricsTracker> metrics_tracker_;
|
||||
|
||||
std::optional<int> first_animation_group_id_;
|
||||
bool started_animations_aborted_ = false;
|
||||
|
@ -17,7 +17,7 @@ namespace ui {
|
||||
class Compositor;
|
||||
class LayerAnimator;
|
||||
|
||||
// Reports cc::FrameSequenceMetrics::ThroughputData of layer animations.
|
||||
// Reports cc::FrameSequenceMetrics::CustomReportData of layer animations.
|
||||
//
|
||||
// Throughput is defined as the ratio between number frames presented (actual
|
||||
// screen updates) for the animations and the number frames expected.
|
||||
@ -26,7 +26,7 @@ class LayerAnimator;
|
||||
//
|
||||
// See also docs/speed/graphics_metrics_definitions.md.
|
||||
//
|
||||
// cc::FrameSequenceMetrics::ThroughputData contains the numbers of produced
|
||||
// cc::FrameSequenceMetrics::CustomReportData contains the numbers of produced
|
||||
// frames and expected frames and could be used to calculate the two metrics.
|
||||
//
|
||||
// All layer animation sequences created after its construction are consider
|
||||
|
@ -14,13 +14,13 @@
|
||||
#include "ui/compositor/layer_animation_sequence.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/scoped_layer_animation_settings.h"
|
||||
#include "ui/compositor/test/animation_throughput_reporter_test_base.h"
|
||||
#include "ui/compositor/test/throughput_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_reporter_test_base.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
using AnimationThroughputReporterTest = AnimationThroughputReporterTestBase;
|
||||
using AnimationThroughputReporterTest = CompositorMetricsReporterTestBase;
|
||||
|
||||
// Tests animation throughput collection with implicit animation scenario.
|
||||
TEST_F(AnimationThroughputReporterTest, ImplicitAnimation) {
|
||||
@ -28,7 +28,7 @@ TEST_F(AnimationThroughputReporterTest, ImplicitAnimation) {
|
||||
layer.SetOpacity(0.5f);
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
{
|
||||
LayerAnimator* animator = layer.GetAnimator();
|
||||
AnimationThroughputReporter reporter(animator,
|
||||
@ -48,7 +48,7 @@ TEST_F(AnimationThroughputReporterTest, ImplicitAnimationLateAttach) {
|
||||
Layer layer;
|
||||
layer.SetOpacity(0.5f);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
{
|
||||
LayerAnimator* animator = layer.GetAnimator();
|
||||
AnimationThroughputReporter reporter(animator,
|
||||
@ -71,7 +71,7 @@ TEST_F(AnimationThroughputReporterTest, ExplicitAnimation) {
|
||||
layer.SetOpacity(0.5f);
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
LayerAnimator* animator = layer.GetAnimator();
|
||||
AnimationThroughputReporter reporter(animator, checker.repeating_callback());
|
||||
|
||||
@ -93,7 +93,7 @@ TEST_F(AnimationThroughputReporterTest, PersistedAnimation) {
|
||||
layer->SetAnimator(animator);
|
||||
|
||||
// |reporter| keeps reporting as long as it is alive.
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
AnimationThroughputReporter reporter(animator, checker.repeating_callback());
|
||||
|
||||
// Report data for animation of opacity goes to 1.
|
||||
@ -112,7 +112,7 @@ TEST_F(AnimationThroughputReporterTest, AbortedAnimation) {
|
||||
layer->SetOpacity(0.5f);
|
||||
root_layer()->Add(layer.get());
|
||||
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
|
||||
// Reporter started monitoring animation, then deleted, which should be
|
||||
// reported when the animation ends.
|
||||
@ -142,7 +142,7 @@ TEST_F(AnimationThroughputReporterTest, LayerDestroyedBeforeReporter) {
|
||||
layer->SetOpacity(0.5f);
|
||||
root_layer()->Add(layer.get());
|
||||
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
LayerAnimator* animator = layer->GetAnimator();
|
||||
AnimationThroughputReporter reporter(animator, checker.repeating_callback());
|
||||
{
|
||||
@ -164,7 +164,7 @@ TEST_F(AnimationThroughputReporterTest, NoReportOnDetach) {
|
||||
layer->SetOpacity(0.5f);
|
||||
root_layer()->Add(layer.get());
|
||||
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
{
|
||||
LayerAnimator* animator = layer->GetAnimator();
|
||||
AnimationThroughputReporter reporter(animator,
|
||||
@ -188,7 +188,7 @@ TEST_F(AnimationThroughputReporterTest, EndDetachedNoReportNoLeak) {
|
||||
auto layer = std::make_unique<Layer>();
|
||||
layer->SetOpacity(0.5f);
|
||||
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
LayerAnimator* animator = layer->GetAnimator();
|
||||
// Schedule an animation without being attached to a root.
|
||||
{
|
||||
@ -216,7 +216,7 @@ TEST_F(AnimationThroughputReporterTest, ReportForAnimateToNewTarget) {
|
||||
layer->SetBounds(gfx::Rect(0, 0, 1, 2));
|
||||
root_layer()->Add(layer.get());
|
||||
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
LayerAnimator* animator = layer->GetAnimator();
|
||||
// Schedule an animation that will be preempted. No report should happen.
|
||||
{
|
||||
@ -229,7 +229,7 @@ TEST_F(AnimationThroughputReporterTest, ReportForAnimateToNewTarget) {
|
||||
}
|
||||
|
||||
// Animate to new target. Report should happen.
|
||||
ThroughputReportChecker checker2(this);
|
||||
CompositorMetricsReportChecker checker2(this);
|
||||
{
|
||||
AnimationThroughputReporter reporter(animator,
|
||||
checker2.repeating_callback());
|
||||
@ -261,7 +261,7 @@ TEST_F(AnimationThroughputReporterTest, NoLeakWithNoAnimationStart) {
|
||||
}
|
||||
|
||||
// Create the reporter with the existing animation.
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
{
|
||||
AnimationThroughputReporter reporter(animator,
|
||||
checker.repeating_callback());
|
||||
@ -277,7 +277,7 @@ TEST_F(AnimationThroughputReporterTest, NoReportForNoRunAnimations) {
|
||||
Layer layer;
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
ThroughputReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
CompositorMetricsReportChecker checker(this, /*fail_if_reported=*/true);
|
||||
{
|
||||
LayerAnimator* animator = layer.GetAnimator();
|
||||
AnimationThroughputReporter reporter(animator,
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include "ui/base/ozone_buildflags.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/compositor_observer.h"
|
||||
#include "ui/compositor/compositor_switches.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
@ -711,9 +712,9 @@ void Compositor::IssueExternalBeginFrame(
|
||||
args, force, std::move(callback));
|
||||
}
|
||||
|
||||
ThroughputTracker Compositor::RequestNewThroughputTracker() {
|
||||
return ThroughputTracker(next_throughput_tracker_id_++,
|
||||
weak_ptr_factory_.GetWeakPtr());
|
||||
CompositorMetricsTracker Compositor::RequestNewCompositorMetricsTracker() {
|
||||
return CompositorMetricsTracker(next_compositor_metrics_tracker_id_++,
|
||||
weak_ptr_factory_.GetWeakPtr());
|
||||
}
|
||||
|
||||
double Compositor::GetPercentDroppedFrames() const {
|
||||
@ -863,25 +864,25 @@ Compositor::TrackerState& Compositor::TrackerState::operator=(TrackerState&&) =
|
||||
default;
|
||||
Compositor::TrackerState::~TrackerState() = default;
|
||||
|
||||
void Compositor::StartThroughputTracker(
|
||||
void Compositor::StartMetricsTracker(
|
||||
TrackerId tracker_id,
|
||||
ThroughputTrackerHost::ReportCallback callback) {
|
||||
DCHECK(!base::Contains(throughput_tracker_map_, tracker_id));
|
||||
CompositorMetricsTrackerHost::ReportCallback callback) {
|
||||
DCHECK(!base::Contains(compositor_metrics_tracker_map_, tracker_id));
|
||||
|
||||
auto& tracker_state = throughput_tracker_map_[tracker_id];
|
||||
auto& tracker_state = compositor_metrics_tracker_map_[tracker_id];
|
||||
tracker_state.report_callback = std::move(callback);
|
||||
|
||||
animation_host_->StartThroughputTracking(tracker_id);
|
||||
}
|
||||
|
||||
bool Compositor::StopThroughputTracker(TrackerId tracker_id) {
|
||||
auto it = throughput_tracker_map_.find(tracker_id);
|
||||
CHECK(it != throughput_tracker_map_.end(), base::NotFatalUntil::M130);
|
||||
bool Compositor::StopMetricsTracker(TrackerId tracker_id) {
|
||||
auto it = compositor_metrics_tracker_map_.find(tracker_id);
|
||||
CHECK(it != compositor_metrics_tracker_map_.end(), base::NotFatalUntil::M130);
|
||||
|
||||
// Clean up if report has happened since StopThroughputTracking would
|
||||
// Clean up if report has happened since StopCompositorMetricsTracking would
|
||||
// not trigger report in this case.
|
||||
if (it->second.report_attempted) {
|
||||
throughput_tracker_map_.erase(it);
|
||||
compositor_metrics_tracker_map_.erase(it);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -890,13 +891,13 @@ bool Compositor::StopThroughputTracker(TrackerId tracker_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Compositor::CancelThroughputTracker(TrackerId tracker_id) {
|
||||
auto it = throughput_tracker_map_.find(tracker_id);
|
||||
CHECK(it != throughput_tracker_map_.end(), base::NotFatalUntil::M130);
|
||||
void Compositor::CancelMetricsTracker(TrackerId tracker_id) {
|
||||
auto it = compositor_metrics_tracker_map_.find(tracker_id);
|
||||
CHECK(it != compositor_metrics_tracker_map_.end(), base::NotFatalUntil::M130);
|
||||
|
||||
const bool should_stop = !it->second.report_attempted;
|
||||
|
||||
throughput_tracker_map_.erase(it);
|
||||
compositor_metrics_tracker_map_.erase(it);
|
||||
|
||||
if (should_stop)
|
||||
animation_host_->StopThroughputTracking(tracker_id);
|
||||
@ -943,21 +944,22 @@ void Compositor::RequestSuccessfulPresentationTimeForNextFrame(
|
||||
void Compositor::ReportMetricsForTracker(
|
||||
int tracker_id,
|
||||
const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
auto it = throughput_tracker_map_.find(tracker_id);
|
||||
if (it == throughput_tracker_map_.end())
|
||||
auto it = compositor_metrics_tracker_map_.find(tracker_id);
|
||||
if (it == compositor_metrics_tracker_map_.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set `report_attempted` but not reporting if relevant ThroughputTrackers
|
||||
// are not stopped and waiting for reports.
|
||||
// Set `report_attempted` but not reporting if relevant
|
||||
// CompositorMetricsTrackers are not stopped and waiting for reports.
|
||||
if (!it->second.should_report) {
|
||||
it->second.report_attempted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Callback may modify `throughput_tracker_map_` so update the map first.
|
||||
// See https://crbug.com/1193382.
|
||||
// Callback may modify `compositor_metrics_tracker_map_` so update the map
|
||||
// first. See https://crbug.com/1193382.
|
||||
auto callback = std::move(it->second.report_callback);
|
||||
throughput_tracker_map_.erase(it);
|
||||
compositor_metrics_tracker_map_.erase(it);
|
||||
std::move(callback).Run(data);
|
||||
}
|
||||
|
||||
|
@ -44,11 +44,10 @@
|
||||
#include "ui/compositor/compositor_animation_observer.h"
|
||||
#include "ui/compositor/compositor_export.h"
|
||||
#include "ui/compositor/compositor_lock.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker_host.h"
|
||||
#include "ui/compositor/compositor_observer.h"
|
||||
#include "ui/compositor/host_begin_frame_observer.h"
|
||||
#include "ui/compositor/layer_animator_collection.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/throughput_tracker_host.h"
|
||||
#include "ui/display/types/display_constants.h"
|
||||
#include "ui/gfx/display_color_spaces.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
@ -59,7 +58,7 @@
|
||||
|
||||
namespace base {
|
||||
class SingleThreadTaskRunner;
|
||||
}
|
||||
} // namespace base
|
||||
|
||||
namespace cc {
|
||||
class AnimationHost;
|
||||
@ -82,13 +81,14 @@ class Size;
|
||||
|
||||
namespace gpu {
|
||||
class GpuMemoryBufferManager;
|
||||
}
|
||||
} // namespace gpu
|
||||
|
||||
namespace viz {
|
||||
namespace mojom {
|
||||
class DisplayPrivate;
|
||||
class ExternalBeginFrameController;
|
||||
} // namespace mojom
|
||||
|
||||
class HostFrameSinkManager;
|
||||
class LocalSurfaceId;
|
||||
class RasterContextProvider;
|
||||
@ -99,7 +99,7 @@ class Compositor;
|
||||
class Layer;
|
||||
class ScopedAnimationDurationScaleMode;
|
||||
class ScrollInputHandler;
|
||||
class ThroughputTracker;
|
||||
class CompositorMetricsTracker;
|
||||
struct PendingBeginFrameArgs;
|
||||
|
||||
constexpr int kCompositorLockTimeoutMs = 67;
|
||||
@ -149,7 +149,7 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
||||
public cc::LayerTreeHostClient,
|
||||
public cc::LayerTreeHostSingleThreadClient,
|
||||
public viz::HostFrameSinkClient,
|
||||
public ThroughputTrackerHost {
|
||||
public CompositorMetricsTrackerHost {
|
||||
public:
|
||||
Compositor(const viz::FrameSinkId& frame_sink_id,
|
||||
ui::ContextFactory* context_factory,
|
||||
@ -377,8 +377,8 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
||||
bool force,
|
||||
base::OnceCallback<void(const viz::BeginFrameAck&)> callback);
|
||||
|
||||
// Creates a ThroughputTracker for tracking this Compositor.
|
||||
ThroughputTracker RequestNewThroughputTracker();
|
||||
// Creates a CompositorMetricsTracker for tracking this Compositor.
|
||||
CompositorMetricsTracker RequestNewCompositorMetricsTracker();
|
||||
|
||||
// Returns a percentage of dropped frames of the last second.
|
||||
double GetPercentDroppedFrames() const;
|
||||
@ -446,12 +446,12 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
||||
void OnFrameTokenChanged(uint32_t frame_token,
|
||||
base::TimeTicks activation_time) override;
|
||||
|
||||
// ThroughputTrackerHost implementation.
|
||||
void StartThroughputTracker(
|
||||
// CompositorMetricsTrackerHost implementation.
|
||||
void StartMetricsTracker(
|
||||
TrackerId tracker_id,
|
||||
ThroughputTrackerHost::ReportCallback callback) override;
|
||||
bool StopThroughputTracker(TrackerId tracker_id) override;
|
||||
void CancelThroughputTracker(TrackerId tracker_id) override;
|
||||
CompositorMetricsTrackerHost::ReportCallback callback) override;
|
||||
bool StopMetricsTracker(TrackerId tracker_id) override;
|
||||
void CancelMetricsTracker(TrackerId tracker_id) override;
|
||||
|
||||
// base::PowerSuspendObserver:
|
||||
void OnResume() override;
|
||||
@ -499,9 +499,9 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
||||
return host_->saved_events_metrics_count_for_testing();
|
||||
}
|
||||
|
||||
// Returns true if there are throughput trackers.
|
||||
bool has_throughput_trackers_for_testing() const {
|
||||
return !throughput_tracker_map_.empty();
|
||||
// Returns true if there are compositor metrics trackers.
|
||||
bool has_compositor_metrics_trackers_for_testing() const {
|
||||
return !compositor_metrics_tracker_map_.empty();
|
||||
}
|
||||
|
||||
const cc::LayerTreeHost* host_for_testing() const { return host_.get(); }
|
||||
@ -641,7 +641,7 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
||||
// See go/report-ux-metrics-at-painting for details.
|
||||
bool animation_started_ = false;
|
||||
|
||||
TrackerId next_throughput_tracker_id_ = 1u;
|
||||
TrackerId next_compositor_metrics_tracker_id_ = 1u;
|
||||
struct TrackerState {
|
||||
TrackerState();
|
||||
TrackerState(TrackerState&&);
|
||||
@ -651,15 +651,17 @@ class COMPOSITOR_EXPORT Compositor : public base::PowerSuspendObserver,
|
||||
// Whether a tracker is waiting for report and `report_callback` should be
|
||||
// invoked. This is set to true when a tracker is stopped.
|
||||
bool should_report = false;
|
||||
|
||||
// Whether the report for a tracker has happened. This is set when an
|
||||
// involuntary report happens before the tracker is stopped and set
|
||||
// `should_report` field above.
|
||||
bool report_attempted = false;
|
||||
|
||||
// Invoked to send report to the owner of a tracker.
|
||||
ThroughputTrackerHost::ReportCallback report_callback;
|
||||
CompositorMetricsTrackerHost::ReportCallback report_callback;
|
||||
};
|
||||
using ThroughputTrackerMap = base::flat_map<TrackerId, TrackerState>;
|
||||
ThroughputTrackerMap throughput_tracker_map_;
|
||||
using CompositorMetricsTrackerMap = base::flat_map<TrackerId, TrackerState>;
|
||||
CompositorMetricsTrackerMap compositor_metrics_tracker_map_;
|
||||
|
||||
base::WeakPtrFactory<Compositor> context_creation_weak_ptr_factory_{this};
|
||||
base::WeakPtrFactory<Compositor> weak_ptr_factory_{this};
|
||||
|
@ -2,26 +2,30 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/functional/callback.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker_host.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
ThroughputTracker::ThroughputTracker(TrackerId id,
|
||||
base::WeakPtr<ThroughputTrackerHost> host)
|
||||
CompositorMetricsTracker::CompositorMetricsTracker(
|
||||
TrackerId id,
|
||||
base::WeakPtr<CompositorMetricsTrackerHost> host)
|
||||
: id_(id), host_(std::move(host)) {
|
||||
DCHECK(host_);
|
||||
}
|
||||
|
||||
ThroughputTracker::ThroughputTracker(ThroughputTracker&& other) {
|
||||
CompositorMetricsTracker::CompositorMetricsTracker(
|
||||
CompositorMetricsTracker&& other) {
|
||||
*this = std::move(other);
|
||||
}
|
||||
|
||||
ThroughputTracker& ThroughputTracker::operator=(ThroughputTracker&& other) {
|
||||
CompositorMetricsTracker& CompositorMetricsTracker::operator=(
|
||||
CompositorMetricsTracker&& other) {
|
||||
id_ = other.id_;
|
||||
host_ = std::move(other.host_);
|
||||
state_ = other.state_;
|
||||
@ -32,26 +36,27 @@ ThroughputTracker& ThroughputTracker::operator=(ThroughputTracker&& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
ThroughputTracker::~ThroughputTracker() {
|
||||
// Auto cancel if `Stop` is not called.
|
||||
CompositorMetricsTracker::~CompositorMetricsTracker() {
|
||||
// Auto cancel if `Stop()` is not called.
|
||||
if (state_ == State::kStarted) {
|
||||
Cancel();
|
||||
}
|
||||
}
|
||||
|
||||
void ThroughputTracker::Start(ThroughputTrackerHost::ReportCallback callback) {
|
||||
// Start after |host_| destruction is likely an error.
|
||||
void CompositorMetricsTracker::Start(
|
||||
CompositorMetricsTrackerHost::ReportCallback callback) {
|
||||
// Start after `host_` destruction is likely an error.
|
||||
DCHECK(host_);
|
||||
DCHECK_EQ(state_, State::kNotStarted);
|
||||
|
||||
state_ = State::kStarted;
|
||||
host_->StartThroughputTracker(id_, std::move(callback));
|
||||
host_->StartMetricsTracker(id_, std::move(callback));
|
||||
}
|
||||
|
||||
bool ThroughputTracker::Stop() {
|
||||
bool CompositorMetricsTracker::Stop() {
|
||||
DCHECK_EQ(state_, State::kStarted);
|
||||
|
||||
if (host_ && host_->StopThroughputTracker(id_)) {
|
||||
if (host_ && host_->StopMetricsTracker(id_)) {
|
||||
state_ = State::kWaitForReport;
|
||||
return true;
|
||||
}
|
||||
@ -62,8 +67,8 @@ bool ThroughputTracker::Stop() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void ThroughputTracker::Cancel() {
|
||||
// Some code calls Cancel() indirectly after receiving report. Allow this to
|
||||
void CompositorMetricsTracker::Cancel() {
|
||||
// Some code calls `Cancel()` indirectly after receiving report. Allow this to
|
||||
// happen and make it a no-op. See https://crbug.com/1193382.
|
||||
if (state_ != State::kStarted) {
|
||||
return;
|
||||
@ -72,15 +77,16 @@ void ThroughputTracker::Cancel() {
|
||||
CancelReport();
|
||||
}
|
||||
|
||||
void ThroughputTracker::CancelReport() {
|
||||
void CompositorMetricsTracker::CancelReport() {
|
||||
// Report is only possible in `kStarted` and `kWaitForReport` state.
|
||||
if (state_ != State::kStarted && state_ != State::kWaitForReport) {
|
||||
return;
|
||||
}
|
||||
|
||||
state_ = State::kCanceled;
|
||||
if (host_)
|
||||
host_->CancelThroughputTracker(id_);
|
||||
if (host_) {
|
||||
host_->CancelMetricsTracker(id_);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
@ -2,38 +2,37 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef UI_COMPOSITOR_THROUGHPUT_TRACKER_H_
|
||||
#define UI_COMPOSITOR_THROUGHPUT_TRACKER_H_
|
||||
#ifndef UI_COMPOSITOR_COMPOSITOR_METRICS_TRACKER_H_
|
||||
#define UI_COMPOSITOR_COMPOSITOR_METRICS_TRACKER_H_
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "ui/compositor/compositor_export.h"
|
||||
#include "ui/compositor/throughput_tracker_host.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker_host.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Compositor;
|
||||
class ThroughputTrackerHost;
|
||||
|
||||
// A class to track the throughput of Compositor. The tracking is identified by
|
||||
// A class to track custom metrics of Compositor. The tracking is identified by
|
||||
// an id. The id is passed into impl side and be used as the sequence id to
|
||||
// create and stop a kCustom typed cc::FrameSequenceTracker. The class is
|
||||
// move-only to have only one holder of the id. When ThroughputTracker is
|
||||
// move-only to have only one holder of the id. When CompositorMetricsTracker is
|
||||
// destroyed with an active tracking, the tracking will be canceled and report
|
||||
// callback will not be invoked.
|
||||
class COMPOSITOR_EXPORT ThroughputTracker {
|
||||
class COMPOSITOR_EXPORT CompositorMetricsTracker {
|
||||
public:
|
||||
using TrackerId = ThroughputTrackerHost::TrackerId;
|
||||
using TrackerId = CompositorMetricsTrackerHost::TrackerId;
|
||||
|
||||
// Move only.
|
||||
ThroughputTracker(ThroughputTracker&& other);
|
||||
ThroughputTracker& operator=(ThroughputTracker&& other);
|
||||
CompositorMetricsTracker(CompositorMetricsTracker&& other);
|
||||
CompositorMetricsTracker& operator=(CompositorMetricsTracker&& other);
|
||||
|
||||
~ThroughputTracker();
|
||||
~CompositorMetricsTracker();
|
||||
|
||||
// Starts tracking Compositor and provides a callback for reporting. The
|
||||
// throughput data collection starts after the next commit.
|
||||
void Start(ThroughputTrackerHost::ReportCallback callback);
|
||||
void Start(CompositorMetricsTrackerHost::ReportCallback callback);
|
||||
|
||||
// Stops tracking. Returns true when the supplied callback will be invoked
|
||||
// when the data collection finishes. Returns false when the data collection
|
||||
@ -61,15 +60,18 @@ class COMPOSITOR_EXPORT ThroughputTracker {
|
||||
};
|
||||
|
||||
// Private since it should only be created via Compositor's
|
||||
// RequestNewThroughputTracker call.
|
||||
ThroughputTracker(TrackerId id, base::WeakPtr<ThroughputTrackerHost> host);
|
||||
// RequestNewMetricsTracker call.
|
||||
CompositorMetricsTracker(TrackerId id,
|
||||
base::WeakPtr<CompositorMetricsTrackerHost> host);
|
||||
|
||||
static const TrackerId kInvalidId = 0u;
|
||||
TrackerId id_ = kInvalidId;
|
||||
base::WeakPtr<ThroughputTrackerHost> host_;
|
||||
base::WeakPtr<CompositorMetricsTrackerHost> host_;
|
||||
State state_ = State::kNotStarted;
|
||||
};
|
||||
|
||||
using ThroughputTracker = CompositorMetricsTracker;
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_COMPOSITOR_THROUGHPUT_TRACKER_H_
|
||||
#endif // UI_COMPOSITOR_COMPOSITOR_METRICS_TRACKER_H_
|
38
ui/compositor/compositor_metrics_tracker_host.h
Normal file
38
ui/compositor/compositor_metrics_tracker_host.h
Normal file
@ -0,0 +1,38 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef UI_COMPOSITOR_COMPOSITOR_METRICS_TRACKER_HOST_H_
|
||||
#define UI_COMPOSITOR_COMPOSITOR_METRICS_TRACKER_HOST_H_
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "cc/metrics/frame_sequence_tracker.h"
|
||||
#include "ui/compositor/compositor_export.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
// An interface for CompositorMetricsTracker to call its host.
|
||||
class COMPOSITOR_EXPORT CompositorMetricsTrackerHost {
|
||||
public:
|
||||
using TrackerId = size_t;
|
||||
|
||||
virtual ~CompositorMetricsTrackerHost() = default;
|
||||
|
||||
// Starts the tracking for the given `tracker_id`. `callback` is invoked after
|
||||
// the tracker is stopped and the metrics data is collected.
|
||||
using ReportCallback = base::OnceCallback<void(
|
||||
const cc::FrameSequenceMetrics::CustomReportData& data)>;
|
||||
virtual void StartMetricsTracker(TrackerId tracker_id,
|
||||
ReportCallback callback) = 0;
|
||||
|
||||
// Stops the tracking for the given `tracker_id`. Returns true if tracking
|
||||
// is stopped successfully. Otherwise, returns false.
|
||||
virtual bool StopMetricsTracker(TrackerId tracker_id) = 0;
|
||||
|
||||
// Cancels the tracking for the given tracker id.
|
||||
virtual void CancelMetricsTracker(TrackerId tracker_id) = 0;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_COMPOSITOR_COMPOSITOR_METRICS_TRACKER_HOST_H_
|
15
ui/compositor/throughput_tracker_unittest.cc → ui/compositor/compositor_metrics_tracker_unittest.cc
15
ui/compositor/throughput_tracker_unittest.cc → ui/compositor/compositor_metrics_tracker_unittest.cc
@ -2,25 +2,28 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
|
||||
#include "base/test/bind.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/test/animation_throughput_reporter_test_base.h"
|
||||
#include "ui/compositor/test/throughput_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_reporter_test_base.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
using ThroughputReporterTest = AnimationThroughputReporterTestBase;
|
||||
using CompositorMetricsReporterTest = CompositorMetricsReporterTestBase;
|
||||
|
||||
TEST_F(ThroughputReporterTest, ThreadCheck) {
|
||||
TEST_F(CompositorMetricsReporterTest, ThreadCheck) {
|
||||
Layer layer;
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
LayerAnimator* animator = new LayerAnimator(base::Milliseconds(32));
|
||||
layer.SetAnimator(animator);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
auto once_callback = checker.once_callback();
|
||||
|
||||
ui::Compositor* c = compositor();
|
||||
@ -29,7 +32,7 @@ TEST_F(ThroughputReporterTest, ThreadCheck) {
|
||||
std::move(once_callback).Run(data);
|
||||
};
|
||||
|
||||
auto tracker = c->RequestNewThroughputTracker();
|
||||
auto tracker = c->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(callback));
|
||||
tracker.Stop();
|
||||
EXPECT_TRUE(checker.WaitUntilReported());
|
@ -22,6 +22,7 @@
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/base/ui_base_features.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/compositor/layer_delegate.h"
|
||||
#include "ui/compositor/test/draw_waiter_for_test.h"
|
||||
@ -285,13 +286,13 @@ TEST_F(CompositorTestWithMockedTime,
|
||||
TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
|
||||
// Move a not started instance.
|
||||
{
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
auto moved_tracker = std::move(tracker);
|
||||
}
|
||||
|
||||
// Move a started instance.
|
||||
{
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
// This should not be called since the tracking is auto canceled.
|
||||
@ -302,7 +303,7 @@ TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
|
||||
|
||||
// Move a started instance and stop.
|
||||
{
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
// May be called since Stop() is called.
|
||||
@ -313,7 +314,7 @@ TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
|
||||
|
||||
// Move a started instance and cancel.
|
||||
{
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
// This should not be called since Cancel() is called.
|
||||
@ -325,7 +326,7 @@ TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
|
||||
|
||||
// Move a stopped instance.
|
||||
{
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
// May be called since Stop() is called.
|
||||
@ -336,7 +337,7 @@ TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
|
||||
|
||||
// Move a canceled instance.
|
||||
{
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
// This should not be called since Cancel() is called.
|
||||
@ -348,8 +349,8 @@ TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// ui::ThroughputTracker is only supported on ChromeOS
|
||||
TEST_F(CompositorTestWithMessageLoop, ThroughputTracker) {
|
||||
// ui::CompositorMetricsTracker is only supported on ChromeOS
|
||||
TEST_F(CompositorTestWithMessageLoop, CompositorMetricsTracker) {
|
||||
auto root_layer = std::make_unique<Layer>(ui::LAYER_SOLID_COLOR);
|
||||
viz::ParentLocalSurfaceIdAllocator allocator;
|
||||
allocator.GenerateId();
|
||||
@ -359,7 +360,8 @@ TEST_F(CompositorTestWithMessageLoop, ThroughputTracker) {
|
||||
allocator.GetCurrentLocalSurfaceId());
|
||||
ASSERT_TRUE(compositor()->IsVisible());
|
||||
|
||||
ThroughputTracker tracker = compositor()->RequestNewThroughputTracker();
|
||||
CompositorMetricsTracker tracker =
|
||||
compositor()->RequestNewCompositorMetricsTracker();
|
||||
|
||||
base::RunLoop run_loop;
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
@ -389,7 +391,7 @@ TEST_F(CompositorTestWithMessageLoop, ThroughputTracker) {
|
||||
}
|
||||
|
||||
TEST_F(CompositorTestWithMessageLoop, ThroughputTrackerOutliveCompositor) {
|
||||
auto tracker = compositor()->RequestNewThroughputTracker();
|
||||
auto tracker = compositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
ADD_FAILURE() << "No report should happen";
|
||||
@ -411,7 +413,8 @@ TEST_F(CompositorTestWithMessageLoop, ThroughputTrackerCallbackStateChange) {
|
||||
allocator.GetCurrentLocalSurfaceId());
|
||||
ASSERT_TRUE(compositor()->IsVisible());
|
||||
|
||||
ThroughputTracker tracker = compositor()->RequestNewThroughputTracker();
|
||||
CompositorMetricsTracker tracker =
|
||||
compositor()->RequestNewCompositorMetricsTracker();
|
||||
|
||||
base::RunLoop run_loop;
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
@ -420,8 +423,8 @@ TEST_F(CompositorTestWithMessageLoop, ThroughputTrackerCallbackStateChange) {
|
||||
tracker.Cancel();
|
||||
|
||||
// Starting another tracker should not DCHECK or crash.
|
||||
ThroughputTracker another_tracker =
|
||||
compositor()->RequestNewThroughputTracker();
|
||||
CompositorMetricsTracker another_tracker =
|
||||
compositor()->RequestNewCompositorMetricsTracker();
|
||||
another_tracker.Start(base::DoNothing());
|
||||
|
||||
run_loop.Quit();
|
||||
@ -456,7 +459,8 @@ TEST_F(CompositorTestWithMessageLoop, ThroughputTrackerInvoluntaryReport) {
|
||||
allocator.GetCurrentLocalSurfaceId());
|
||||
ASSERT_TRUE(compositor()->IsVisible());
|
||||
|
||||
ThroughputTracker tracker = compositor()->RequestNewThroughputTracker();
|
||||
CompositorMetricsTracker tracker =
|
||||
compositor()->RequestNewCompositorMetricsTracker();
|
||||
|
||||
tracker.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
|
@ -2,24 +2,25 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ui/compositor/test/throughput_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_report_checker.h"
|
||||
|
||||
#include "base/time/time.h"
|
||||
#include "ui/compositor/test/animation_throughput_reporter_test_base.h"
|
||||
#include "ui/compositor/test/compositor_metrics_reporter_test_base.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
bool ThroughputReportChecker::WaitUntilReported() {
|
||||
bool CompositorMetricsReportChecker::WaitUntilReported() {
|
||||
DCHECK(!reported_);
|
||||
test_base_->Advance(base::Seconds(5));
|
||||
return reported_;
|
||||
}
|
||||
|
||||
void ThroughputReportChecker::OnReport(
|
||||
void CompositorMetricsReportChecker::OnReport(
|
||||
const cc::FrameSequenceMetrics::CustomReportData&) {
|
||||
reported_ = true;
|
||||
if (fail_if_reported_)
|
||||
if (fail_if_reported_) {
|
||||
ADD_FAILURE() << "It should not be reported.";
|
||||
}
|
||||
test_base_->QuitRunLoop();
|
||||
}
|
||||
|
@ -2,41 +2,43 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef UI_COMPOSITOR_TEST_THROUGHPUT_REPORT_CHECKER_H_
|
||||
#define UI_COMPOSITOR_TEST_THROUGHPUT_REPORT_CHECKER_H_
|
||||
#ifndef UI_COMPOSITOR_TEST_COMPOSITOR_METRICS_REPORT_CHECKER_H_
|
||||
#define UI_COMPOSITOR_TEST_COMPOSITOR_METRICS_REPORT_CHECKER_H_
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "cc/metrics/frame_sequence_metrics.h"
|
||||
|
||||
namespace ui {
|
||||
class AnimationThroughputReporterTestBase;
|
||||
class CompositorMetricsReporterTestBase;
|
||||
|
||||
class ThroughputReportChecker {
|
||||
class CompositorMetricsReportChecker {
|
||||
public:
|
||||
using ReportRepeatingCallback = base::RepeatingCallback<void(
|
||||
const cc::FrameSequenceMetrics::CustomReportData&)>;
|
||||
using ReportOnceCallback = base::OnceCallback<void(
|
||||
const cc::FrameSequenceMetrics::CustomReportData&)>;
|
||||
|
||||
explicit ThroughputReportChecker(
|
||||
AnimationThroughputReporterTestBase* test_base,
|
||||
explicit CompositorMetricsReportChecker(
|
||||
CompositorMetricsReporterTestBase* test_base,
|
||||
bool fail_if_reported = false)
|
||||
: test_base_(test_base), fail_if_reported_(fail_if_reported) {}
|
||||
ThroughputReportChecker(const ThroughputReportChecker&) = delete;
|
||||
ThroughputReportChecker& operator=(const ThroughputReportChecker&) = delete;
|
||||
~ThroughputReportChecker() = default;
|
||||
CompositorMetricsReportChecker(const CompositorMetricsReportChecker&) =
|
||||
delete;
|
||||
CompositorMetricsReportChecker& operator=(
|
||||
const CompositorMetricsReportChecker&) = delete;
|
||||
~CompositorMetricsReportChecker() = default;
|
||||
|
||||
bool reported() const { return reported_; }
|
||||
|
||||
void reset() { reported_ = false; }
|
||||
|
||||
ReportRepeatingCallback repeating_callback() {
|
||||
return base::BindRepeating(&ThroughputReportChecker::OnReport,
|
||||
return base::BindRepeating(&CompositorMetricsReportChecker::OnReport,
|
||||
base::Unretained(this));
|
||||
}
|
||||
ReportOnceCallback once_callback() {
|
||||
return base::BindOnce(&ThroughputReportChecker::OnReport,
|
||||
return base::BindOnce(&CompositorMetricsReportChecker::OnReport,
|
||||
base::Unretained(this));
|
||||
}
|
||||
|
||||
@ -47,11 +49,11 @@ class ThroughputReportChecker {
|
||||
private:
|
||||
void OnReport(const cc::FrameSequenceMetrics::CustomReportData&);
|
||||
|
||||
raw_ptr<AnimationThroughputReporterTestBase> test_base_;
|
||||
raw_ptr<CompositorMetricsReporterTestBase> test_base_;
|
||||
bool reported_ = false;
|
||||
bool fail_if_reported_ = false;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_COMPOSITOR_TEST_THROUGHPUT_REPORT_CHECKER_H_
|
||||
#endif // UI_COMPOSITOR_TEST_COMPOSITOR_METRICS_REPORT_CHECKER_H_
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ui/compositor/test/animation_throughput_reporter_test_base.h"
|
||||
#include "ui/compositor/test/compositor_metrics_reporter_test_base.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -15,12 +15,12 @@
|
||||
|
||||
namespace ui {
|
||||
|
||||
AnimationThroughputReporterTestBase::AnimationThroughputReporterTestBase() =
|
||||
CompositorMetricsReporterTestBase::CompositorMetricsReporterTestBase() =
|
||||
default;
|
||||
AnimationThroughputReporterTestBase::~AnimationThroughputReporterTestBase() =
|
||||
CompositorMetricsReporterTestBase::~CompositorMetricsReporterTestBase() =
|
||||
default;
|
||||
|
||||
void AnimationThroughputReporterTestBase::SetUp() {
|
||||
void CompositorMetricsReporterTestBase::SetUp() {
|
||||
context_factories_ = std::make_unique<TestContextFactories>(false);
|
||||
|
||||
const gfx::Rect bounds(100, 100);
|
||||
@ -32,24 +32,23 @@ void AnimationThroughputReporterTestBase::SetUp() {
|
||||
|
||||
frame_generation_timer_.Start(
|
||||
FROM_HERE, base::Milliseconds(16), this,
|
||||
&AnimationThroughputReporterTestBase::GenerateOneFrame);
|
||||
&CompositorMetricsReporterTestBase::GenerateOneFrame);
|
||||
}
|
||||
|
||||
void AnimationThroughputReporterTestBase::TearDown() {
|
||||
void CompositorMetricsReporterTestBase::TearDown() {
|
||||
frame_generation_timer_.Stop();
|
||||
host_.reset();
|
||||
context_factories_.reset();
|
||||
}
|
||||
|
||||
void AnimationThroughputReporterTestBase::Advance(
|
||||
const base::TimeDelta& delta) {
|
||||
void CompositorMetricsReporterTestBase::Advance(const base::TimeDelta& delta) {
|
||||
run_loop_ = std::make_unique<base::RunLoop>();
|
||||
base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
|
||||
FROM_HERE, run_loop_->QuitClosure(), delta);
|
||||
run_loop_->Run();
|
||||
}
|
||||
|
||||
void AnimationThroughputReporterTestBase::QuitRunLoop() {
|
||||
void CompositorMetricsReporterTestBase::QuitRunLoop() {
|
||||
run_loop_->Quit();
|
||||
}
|
||||
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef UI_COMPOSITOR_TEST_ANIMATION_THROUGHPUT_REPORTER_TEST_BASE_H_
|
||||
#define UI_COMPOSITOR_TEST_ANIMATION_THROUGHPUT_REPORTER_TEST_BASE_H_
|
||||
#ifndef UI_COMPOSITOR_TEST_COMPOSITOR_METRICS_REPORTER_TEST_BASE_H_
|
||||
#define UI_COMPOSITOR_TEST_COMPOSITOR_METRICS_REPORTER_TEST_BASE_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -21,14 +21,14 @@ class RunLoop;
|
||||
namespace ui {
|
||||
class TestContextFactories;
|
||||
|
||||
class AnimationThroughputReporterTestBase : public testing::Test {
|
||||
class CompositorMetricsReporterTestBase : public testing::Test {
|
||||
public:
|
||||
AnimationThroughputReporterTestBase();
|
||||
AnimationThroughputReporterTestBase(
|
||||
const AnimationThroughputReporterTestBase&) = delete;
|
||||
AnimationThroughputReporterTestBase& operator=(
|
||||
const AnimationThroughputReporterTestBase&) = delete;
|
||||
~AnimationThroughputReporterTestBase() override;
|
||||
CompositorMetricsReporterTestBase();
|
||||
CompositorMetricsReporterTestBase(const CompositorMetricsReporterTestBase&) =
|
||||
delete;
|
||||
CompositorMetricsReporterTestBase& operator=(
|
||||
const CompositorMetricsReporterTestBase&) = delete;
|
||||
~CompositorMetricsReporterTestBase() override;
|
||||
|
||||
// testing::Test:
|
||||
void SetUp() override;
|
||||
@ -61,4 +61,4 @@ class AnimationThroughputReporterTestBase : public testing::Test {
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_COMPOSITOR_TEST_ANIMATION_THROUGHPUT_REPORTER_TEST_BASE_H_
|
||||
#endif // UI_COMPOSITOR_TEST_COMPOSITOR_METRICS_REPORTER_TEST_BASE_H_
|
@ -1,38 +0,0 @@
|
||||
// Copyright 2020 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef UI_COMPOSITOR_THROUGHPUT_TRACKER_HOST_H_
|
||||
#define UI_COMPOSITOR_THROUGHPUT_TRACKER_HOST_H_
|
||||
|
||||
#include "base/functional/callback_forward.h"
|
||||
#include "cc/metrics/frame_sequence_tracker.h"
|
||||
#include "ui/compositor/compositor_export.h"
|
||||
|
||||
namespace ui {
|
||||
|
||||
// An interface for ThroughputTracker to call its host.
|
||||
class COMPOSITOR_EXPORT ThroughputTrackerHost {
|
||||
public:
|
||||
using TrackerId = size_t;
|
||||
|
||||
virtual ~ThroughputTrackerHost() = default;
|
||||
|
||||
// Starts the tracking for the given tracker id. |callback| is invoked after
|
||||
// the tracker is stopped and the metrics data is collected.
|
||||
using ReportCallback = base::OnceCallback<void(
|
||||
const cc::FrameSequenceMetrics::CustomReportData& data)>;
|
||||
virtual void StartThroughputTracker(TrackerId tracker_id,
|
||||
ReportCallback callback) = 0;
|
||||
|
||||
// Stops the tracking for the given tracker id. Returns true if tracking
|
||||
// is stopped successfully. Otherwise, returns false.
|
||||
virtual bool StopThroughputTracker(TrackerId tracker_id) = 0;
|
||||
|
||||
// Cancels the tracking for the given tracker id.
|
||||
virtual void CancelThroughputTracker(TrackerId tracker_id) = 0;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
||||
#endif // UI_COMPOSITOR_THROUGHPUT_TRACKER_HOST_H_
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "ui/compositor/total_animation_throughput_reporter.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
|
||||
@ -41,8 +40,9 @@ TotalAnimationThroughputReporter::TotalAnimationThroughputReporter(
|
||||
/*should_delete=*/false) {}
|
||||
|
||||
TotalAnimationThroughputReporter::~TotalAnimationThroughputReporter() {
|
||||
if (throughput_tracker_)
|
||||
throughput_tracker_->Cancel();
|
||||
if (compositor_metrics_tracker_) {
|
||||
compositor_metrics_tracker_->Cancel();
|
||||
}
|
||||
if (compositor_)
|
||||
compositor_->RemoveObserver(this);
|
||||
compositor_ = nullptr;
|
||||
@ -50,11 +50,12 @@ TotalAnimationThroughputReporter::~TotalAnimationThroughputReporter() {
|
||||
|
||||
void TotalAnimationThroughputReporter::OnFirstAnimationStarted(
|
||||
ui::Compositor* compositor) {
|
||||
if (!throughput_tracker_) {
|
||||
if (!compositor_metrics_tracker_) {
|
||||
timestamp_first_animation_started_at_ = base::TimeTicks::Now();
|
||||
|
||||
throughput_tracker_ = compositor->RequestNewThroughputTracker();
|
||||
throughput_tracker_->Start(base::BindRepeating(
|
||||
compositor_metrics_tracker_ =
|
||||
compositor->RequestNewCompositorMetricsTracker();
|
||||
compositor_metrics_tracker_->Start(base::BindRepeating(
|
||||
&TotalAnimationThroughputReporter::Report, ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
}
|
||||
@ -66,8 +67,8 @@ void TotalAnimationThroughputReporter::OnFirstNonAnimatedFrameStarted(
|
||||
|
||||
timestamp_last_animation_finished_at_ = base::TimeTicks::Now();
|
||||
|
||||
throughput_tracker_->Stop();
|
||||
throughput_tracker_.reset();
|
||||
compositor_metrics_tracker_->Stop();
|
||||
compositor_metrics_tracker_.reset();
|
||||
// Stop observing if no need to report multiple times.
|
||||
if (report_repeating_callback_.is_null())
|
||||
compositor_->RemoveObserver(this);
|
||||
@ -75,9 +76,9 @@ void TotalAnimationThroughputReporter::OnFirstNonAnimatedFrameStarted(
|
||||
|
||||
void TotalAnimationThroughputReporter::OnCompositingShuttingDown(
|
||||
ui::Compositor* compositor) {
|
||||
if (throughput_tracker_) {
|
||||
throughput_tracker_->Cancel();
|
||||
throughput_tracker_.reset();
|
||||
if (compositor_metrics_tracker_) {
|
||||
compositor_metrics_tracker_->Cancel();
|
||||
compositor_metrics_tracker_.reset();
|
||||
}
|
||||
compositor->RemoveObserver(this);
|
||||
compositor_ = nullptr;
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "base/time/time.h"
|
||||
#include "cc/metrics/frame_sequence_metrics.h"
|
||||
#include "ui/compositor/compositor_export.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/compositor_observer.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
|
||||
namespace ash {
|
||||
class LoginUnlockThroughputRecorderTestBase;
|
||||
@ -96,7 +96,9 @@ class COMPOSITOR_EXPORT TotalAnimationThroughputReporter
|
||||
|
||||
base::WeakPtr<ui::TotalAnimationThroughputReporter> GetWeakPtr();
|
||||
|
||||
bool IsMeasuringForTesting() const { return bool{throughput_tracker_}; }
|
||||
bool IsMeasuringForTesting() const {
|
||||
return compositor_metrics_tracker_.has_value();
|
||||
}
|
||||
|
||||
// The returned scope will delay the animation report until the next
|
||||
// |OnFirstNonAnimatedFrameStarted| received after it is destructed. See
|
||||
@ -120,11 +122,11 @@ class COMPOSITOR_EXPORT TotalAnimationThroughputReporter
|
||||
ReportRepeatingCallback report_repeating_callback_;
|
||||
ReportOnceCallback report_once_callback_;
|
||||
bool should_delete_ = false;
|
||||
std::optional<ThroughputTracker> throughput_tracker_;
|
||||
std::optional<CompositorMetricsTracker> compositor_metrics_tracker_;
|
||||
|
||||
// These are always recorderd in pairs. Specifically,
|
||||
// These are always recorded in pairs. Specifically,
|
||||
// `timestamp_first_animation_started_at_` is recorded when
|
||||
// `throughput_tracker_` is created/started, and
|
||||
// `compositor_metrics_tracker_` is created/started, and
|
||||
// `timestamp_last_animation_finished_at_` is recorded when the tracker is
|
||||
// stopped/destructed.
|
||||
base::TimeTicks timestamp_first_animation_started_at_;
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "ui/compositor/layer_animation_sequence.h"
|
||||
#include "ui/compositor/layer_animator.h"
|
||||
#include "ui/compositor/scoped_layer_animation_settings.h"
|
||||
#include "ui/compositor/test/animation_throughput_reporter_test_base.h"
|
||||
#include "ui/compositor/test/throughput_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_report_checker.h"
|
||||
#include "ui/compositor/test/compositor_metrics_reporter_test_base.h"
|
||||
|
||||
#if defined(ADDRESS_SANITIZER) || defined(MEMORY_SANITIZER) || \
|
||||
defined(THREAD_SANITIZER) || defined(LEAK_SANITIZER) || \
|
||||
@ -100,9 +100,9 @@ class TestCompositorMonitor : public ui::CompositorObserver {
|
||||
};
|
||||
|
||||
TotalAnimationThroughputReporter::ReportOnceCallback IgnoreTimestamps(
|
||||
ThroughputReportChecker::ReportOnceCallback original) {
|
||||
CompositorMetricsReportChecker::ReportOnceCallback original) {
|
||||
return base::BindOnce(
|
||||
[](ThroughputReportChecker::ReportOnceCallback original,
|
||||
[](CompositorMetricsReportChecker::ReportOnceCallback original,
|
||||
const cc::FrameSequenceMetrics::CustomReportData& data,
|
||||
base::TimeTicks first_animation_started_at,
|
||||
base::TimeTicks last_animation_finished_at) {
|
||||
@ -113,15 +113,14 @@ TotalAnimationThroughputReporter::ReportOnceCallback IgnoreTimestamps(
|
||||
|
||||
} // namespace
|
||||
|
||||
using TotalAnimationThroughputReporterTest =
|
||||
AnimationThroughputReporterTestBase;
|
||||
using TotalAnimationThroughputReporterTest = CompositorMetricsReporterTestBase;
|
||||
|
||||
TEST_F(TotalAnimationThroughputReporterTest, SingleAnimation) {
|
||||
Layer layer;
|
||||
layer.SetOpacity(0.5f);
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TestCompositorMonitor compositor_monitor(compositor());
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
@ -152,7 +151,7 @@ TEST_F(TotalAnimationThroughputReporterTest, StopAnimation) {
|
||||
layer.SetOpacity(0.5f);
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
SetLayerOpacity(layer, 1.0f, base::Milliseconds(64));
|
||||
@ -169,7 +168,7 @@ TEST_F(TotalAnimationThroughputReporterTest, DISABLED_MultipleAnimations) {
|
||||
layer1.SetOpacity(0.5f);
|
||||
root_layer()->Add(&layer1);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
SetLayerOpacity(layer1, 1.0f, base::Milliseconds(48));
|
||||
@ -202,7 +201,7 @@ TEST_F(TotalAnimationThroughputReporterTest, MultipleAnimationsOnSingleLayer) {
|
||||
layer.SetLayerBrightness(0.5f);
|
||||
root_layer()->Add(&layer);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
SetLayerOpacity(layer, 1.0f, base::Milliseconds(48));
|
||||
@ -227,7 +226,7 @@ TEST_F(TotalAnimationThroughputReporterTest,
|
||||
layer1.SetOpacity(0.5f);
|
||||
root_layer()->Add(&layer1);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
SetLayerOpacity(layer1, 1.0f, base::Milliseconds(48));
|
||||
@ -263,7 +262,7 @@ TEST_F(TotalAnimationThroughputReporterTest, RemoveWhileAnimating) {
|
||||
layer1->SetOpacity(0.5f);
|
||||
root_layer()->Add(layer1.get());
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
SetLayerOpacity(*layer1, 1.0f, base::Milliseconds(100));
|
||||
@ -289,7 +288,7 @@ TEST_F(TotalAnimationThroughputReporterTest, StartWhileAnimating) {
|
||||
|
||||
SetLayerOpacity(layer, 1.0f, base::Milliseconds(96));
|
||||
Advance(base::Milliseconds(32));
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
EXPECT_TRUE(reporter.IsMeasuringForTesting());
|
||||
@ -307,7 +306,7 @@ TEST_F(TotalAnimationThroughputReporterTest, PersistedAnimation) {
|
||||
layer.SetAnimator(animator);
|
||||
|
||||
// |reporter| keeps reporting as long as it is alive.
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(compositor(),
|
||||
checker.repeating_callback());
|
||||
|
||||
@ -376,7 +375,7 @@ TEST_F(TotalAnimationThroughputReporterTest, OnceReporter) {
|
||||
LayerAnimator* animator = new LayerAnimator(base::Milliseconds(32));
|
||||
layer.SetAnimator(animator);
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
TotalAnimationThroughputReporter reporter(
|
||||
compositor(), IgnoreTimestamps(checker.once_callback()),
|
||||
/*should_delete=*/false);
|
||||
@ -487,9 +486,9 @@ TEST_F(TotalAnimationThroughputReporterTest, ThreadCheck) {
|
||||
|
||||
ui::Compositor* c = compositor();
|
||||
|
||||
ThroughputReportChecker checker(this);
|
||||
CompositorMetricsReportChecker checker(this);
|
||||
auto once_callback = checker.once_callback();
|
||||
ThroughputReportChecker::ReportOnceCallback callback =
|
||||
CompositorMetricsReportChecker::ReportOnceCallback callback =
|
||||
base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
// This call with fail if this is called on impl thread.
|
||||
|
@ -6,8 +6,8 @@
|
||||
|
||||
#include "base/test/bind.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "ui/compositor/compositor_metrics_tracker.h"
|
||||
#include "ui/compositor/test/draw_waiter_for_test.h"
|
||||
#include "ui/compositor/throughput_tracker.h"
|
||||
#include "ui/gfx/animation/linear_animation.h"
|
||||
#include "ui/views/animation/animation_delegate_views.h"
|
||||
#include "ui/views/buildflags.h"
|
||||
@ -72,7 +72,7 @@ class TestAnimationDelegateViews : public AnimationDelegateViews {
|
||||
} // namespace
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
// Tests that ui::ThroughputTracker will report for gfx::Animation. Only
|
||||
// Tests that ui::CompositorMetricsTracker will report for gfx::Animation. Only
|
||||
// supported on ChromeOS.
|
||||
TEST_F(CompositorAnimationRunnerTest, ThroughputTracker) {
|
||||
WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
|
||||
@ -91,8 +91,8 @@ TEST_F(CompositorAnimationRunnerTest, ThroughputTracker) {
|
||||
base::RepeatingTimer interval_timer;
|
||||
base::RunLoop run_loop;
|
||||
|
||||
ui::ThroughputTracker tracker1 =
|
||||
widget->GetCompositor()->RequestNewThroughputTracker();
|
||||
ui::CompositorMetricsTracker tracker1 =
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker1.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
++report_count;
|
||||
@ -118,8 +118,8 @@ TEST_F(CompositorAnimationRunnerTest, ThroughputTracker) {
|
||||
// expected.
|
||||
base::RunLoop run_loop2;
|
||||
|
||||
ui::ThroughputTracker tracker2 =
|
||||
widget->GetCompositor()->RequestNewThroughputTracker();
|
||||
ui::CompositorMetricsTracker tracker2 =
|
||||
widget->GetCompositor()->RequestNewCompositorMetricsTracker();
|
||||
tracker2.Start(base::BindLambdaForTesting(
|
||||
[&](const cc::FrameSequenceMetrics::CustomReportData& data) {
|
||||
++report_count2;
|
||||
|
Reference in New Issue
Block a user