From 09f1d8f9b7353b17fe5da6000ff62cc011591f50 Mon Sep 17 00:00:00 2001 From: vadimt Date: Wed, 2 Jun 2021 14:09:08 -0700 Subject: [PATCH] Postponing CUJ_QUICK_SWITCH and CUJ_APP_CLOSE_TO_HOME Now starting at the first drawn frame. Test: perfetto Bug: 188645726 Change-Id: I035f225f5afe64cf6eafa9ba40cffffce0a9d8cc --- .../android/quickstep/AbsSwipeUpHandler.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 005e9b5a7d..c05fb3fb30 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -741,10 +741,25 @@ public abstract class AbsSwipeUpHandler, TaskUtils.closeSystemWindowsAsync(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); if (mRecentsView != null) { - InteractionJankMonitorWrapper.begin(mRecentsView, - InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); - InteractionJankMonitorWrapper.begin(mRecentsView, - InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + mRecentsView.getViewTreeObserver().addOnDrawListener(new OnDrawListener() { + boolean mHandled = false; + + @Override + public void onDraw() { + if (mHandled) { + return; + } + mHandled = true; + + InteractionJankMonitorWrapper.begin(mRecentsView, + InteractionJankMonitorWrapper.CUJ_QUICK_SWITCH, 2000 /* ms timeout */); + InteractionJankMonitorWrapper.begin(mRecentsView, + InteractionJankMonitorWrapper.CUJ_APP_CLOSE_TO_HOME); + + mRecentsView.post(() -> + mRecentsView.getViewTreeObserver().removeOnDrawListener(this)); + } + }); } notifyGestureStartedAsync(); setIsLikelyToStartNewTask(isLikelyToStartNewTask, false /* animate */);