Commit a6a1fcd7 authored by Yichen Zhou's avatar Yichen Zhou Committed by Commit Bot

Add animation smoothness metrics for tab hover card animation.

Add animation smoothness metrics for fade-in/fade-out animation of tab
hover card. It uses ThroughputTracker to track throughput and calculate
smoothness.

Bug: 1060816
Change-Id: I5e9c15a9a5b4320214c1cc27a1deae9230466ec6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2231583Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Yichen Zhou <yichenz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776242}
parent 1385d6a0
......@@ -49,10 +49,32 @@
#include "ui/base/win/shell.h"
#endif
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/metrics_util.h"
#endif
namespace {
// Maximum number of lines that a title label occupies.
constexpr int kHoverCardTitleMaxLines = 2;
#if defined(OS_CHROMEOS)
// UMA histograms that record animation smoothness for fade-in and fade-out
// animations of tab hover card.
constexpr char kHoverCardFadeInSmoothnessHistogramName[] =
"Chrome.Tabs.AnimationSmoothness.HoverCard.FadeIn";
constexpr char kHoverCardFadeOutSmoothnessHistogramName[] =
"Chrome.Tabs.AnimationSmoothness.HoverCard.FadeOut";
void RecordFadeInSmoothness(int smoothness) {
UMA_HISTOGRAM_PERCENTAGE(kHoverCardFadeInSmoothnessHistogramName, smoothness);
}
void RecordFadeOutSmoothness(int smoothness) {
UMA_HISTOGRAM_PERCENTAGE(kHoverCardFadeOutSmoothnessHistogramName,
smoothness);
}
#endif
bool AreHoverCardImagesEnabled() {
return base::FeatureList::IsEnabled(features::kTabHoverCardImages);
}
......@@ -120,8 +142,13 @@ class TabHoverCardBubbleView::WidgetFadeAnimationDelegate
explicit WidgetFadeAnimationDelegate(views::Widget* hover_card)
: AnimationDelegateViews(hover_card->GetRootView()),
widget_(hover_card),
fade_animation_(std::make_unique<gfx::LinearAnimation>(this)) {}
~WidgetFadeAnimationDelegate() override {}
#if defined(OS_CHROMEOS)
throughput_tracker_(
hover_card->GetCompositor()->RequestNewThroughputTracker()),
#endif
fade_animation_(std::make_unique<gfx::LinearAnimation>(this)) {
}
~WidgetFadeAnimationDelegate() override = default;
enum class FadeAnimationState {
// No animation is running.
......@@ -153,6 +180,10 @@ class TabHoverCardBubbleView::WidgetFadeAnimationDelegate
widget_->Show();
fade_animation_ = std::make_unique<gfx::LinearAnimation>(this);
fade_animation_->SetDuration(kFadeInDuration);
#if defined(OS_CHROMEOS)
throughput_tracker_.Start(ash::metrics_util::ForSmoothness(
base::BindRepeating(&RecordFadeInSmoothness)));
#endif
fade_animation_->Start();
}
......@@ -164,6 +195,10 @@ class TabHoverCardBubbleView::WidgetFadeAnimationDelegate
fade_animation_ = std::make_unique<gfx::LinearAnimation>(this);
set_animation_state(FadeAnimationState::FADE_OUT);
fade_animation_->SetDuration(kFadeOutDuration);
#if defined(OS_CHROMEOS)
throughput_tracker_.Start(ash::metrics_util::ForSmoothness(
base::BindRepeating(&RecordFadeOutSmoothness)));
#endif
fade_animation_->Start();
}
......@@ -172,6 +207,9 @@ class TabHoverCardBubbleView::WidgetFadeAnimationDelegate
return;
fade_animation_->Stop();
#if defined(OS_CHROMEOS)
throughput_tracker_.Cancel();
#endif
set_animation_state(FadeAnimationState::IDLE);
widget_->SetOpacity(1.0f);
}
......@@ -197,10 +235,16 @@ class TabHoverCardBubbleView::WidgetFadeAnimationDelegate
void AnimationEnded(const gfx::Animation* animation) override {
AnimationProgressed(animation);
#if defined(OS_CHROMEOS)
throughput_tracker_.Stop();
#endif
set_animation_state(FadeAnimationState::IDLE);
}
views::Widget* const widget_;
#if defined(OS_CHROMEOS)
ui::ThroughputTracker throughput_tracker_;
#endif
std::unique_ptr<gfx::LinearAnimation> fade_animation_;
FadeAnimationState animation_state_ = FadeAnimationState::IDLE;
......
......@@ -25161,6 +25161,27 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Chrome.Tabs.AnimationSmoothness.HoverCard.FadeIn" units="%"
expires_after="2021-06-04">
<owner>yichenz@chromium.org</owner>
s
<owner>chromeos-wmp@google.com</owner>
<summary>
Tracks the animation smoothness for the fade-in animation of tab hover card.
</summary>
</histogram>
<histogram name="Chrome.Tabs.AnimationSmoothness.HoverCard.FadeOut" units="%"
expires_after="2021-06-04">
<owner>yichenz@chromium.org</owner>
s
<owner>chromeos-wmp@google.com</owner>
<summary>
Tracks the animation smoothness for the fade-out animation of tab hover
card.
</summary>
</histogram>
<histogram name="Chrome.UmaPageloadCounter" enum="BooleanHit"
expires_after="2017-06-06">
<obsolete>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment