Commit 6433ae06 authored by kkimlabs's avatar kkimlabs Committed by Commit bot

[Android] Measure AppMenu animation jankiness by frame times UMA.

AppMenu animation is known to be very janky on some low-end devices.
It will be helpful to indentify what devices are having this issue
through UMA.

TBR=isherman@chromium.org
BUG=461066

Review URL: https://codereview.chromium.org/960913003

Cr-Commit-Position: refs/heads/master@{#318778}
parent 4ed25195
......@@ -5,6 +5,7 @@
package org.chromium.chrome.browser.appmenu;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorSet;
import android.content.Context;
import android.content.res.Resources;
......@@ -27,6 +28,7 @@ import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import org.chromium.base.AnimationFrameTimeHistogram;
import org.chromium.base.SysUtils;
import org.chromium.chrome.R;
......@@ -53,6 +55,9 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
private AppMenuHandler mHandler;
private int mCurrentScreenRotation = -1;
private boolean mIsByHardwareButton;
private AnimatorSet mMenuItemEnterAnimator;
private AnimatorListener mAnimationHistogramRecorder = AnimationFrameTimeHistogram
.getAnimatorRecorder("WrenchMenu.OpeningAnimationFrameTimes");
/**
* Creates and sets up the App Menu.
......@@ -140,6 +145,10 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
if (mPopup.getAnchorView() instanceof ImageButton) {
((ImageButton) mPopup.getAnchorView()).setSelected(false);
}
if (mMenuItemEnterAnimator != null) mMenuItemEnterAnimator.cancel();
mHandler.appMenuDismissed();
mHandler.onMenuVisibilityChanged(false);
}
});
......@@ -299,7 +308,6 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
* Dismisses the app menu and cancels the drag-to-scroll if it is taking place.
*/
void dismiss() {
mHandler.appMenuDismissed();
if (isShowing()) {
mPopup.dismiss();
}
......@@ -361,7 +369,7 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
}
private void runMenuItemEnterAnimations() {
AnimatorSet animation = new AnimatorSet();
mMenuItemEnterAnimator = new AnimatorSet();
AnimatorSet.Builder builder = null;
ViewGroup list = mPopup.getListView();
......@@ -370,13 +378,14 @@ public class AppMenu implements OnItemClickListener, OnKeyListener {
Object animatorObject = view.getTag(R.id.menu_item_enter_anim_id);
if (animatorObject != null) {
if (builder == null) {
builder = animation.play((Animator) animatorObject);
builder = mMenuItemEnterAnimator.play((Animator) animatorObject);
} else {
builder.with((Animator) animatorObject);
}
}
}
animation.start();
mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder);
mMenuItemEnterAnimator.start();
}
}
......@@ -43788,6 +43788,16 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>Number of times that each menu item is clicked.</summary>
</histogram>
<histogram name="WrenchMenu.OpeningAnimationFrameTimes" units="milliseconds">
<owner>kkimlabs@chromium.org</owner>
<summary>
Frame times of Android wrench menu opening animation. For example, if the
menu opening animation ran exactly at 60fps for a second, then each frame
time is 16ms. Therefore total ~60 number of 16ms value will be recorded. If
the anmation was janky, we will see >16ms data points in the histogram.
</summary>
</histogram>
<histogram name="WrenchMenu.RecentTabsSubMenu" enum="RecentTabsAction">
<owner>rpop@chromium.org</owner>
<summary>
......@@ -43805,7 +43815,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</histogram>
<histogram name="WrenchMenu.TouchDuration" units="milliseconds">
<owner>kkimlabs@google.com</owner>
<owner>kkimlabs@chromium.org</owner>
<summary>
Time difference between touch down and touch up on Android wrench button.
</summary>
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