From dc9385aad49bf2ba24c1221a5d4558a1ac69f97a Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Sat, 13 May 2017 02:00:31 +0200 Subject: [PATCH] Immediately report drawing No need to wait on the next relayout - this can only delay the transition. Makes hot launches a lot more consistent. However, this made it too fast! We then hit a race condition when the app transition was already starting but no other layout was done yet. When another layout was executed we noticed that we need to report resized for the starting window, clearing it's drawn state, which set startingDisplayed=false, which jumped the app window animation to the end. To fix this, make sure not to report another resized immediately after the initial layout, as the client already knows the latest (because it calls relayout at some point before it starts drawing). Also fix "animating" async systrace for better analysis. Test: Open/close size-mismatching task snapshot 100 times, ensure no animation skipped. Test: Look at app transition logs, ensure more consistent. Test: Overall system sanity testing (open a couple of apps/dialogs etc). Bug: 32668632 Change-Id: Id795cd6a84f22e6a619089cb9554fc5033477ad2 --- .../android/server/wm/AppWindowAnimator.java | 4 ++- .../com/android/server/wm/DisplayContent.java | 7 +++++ .../server/wm/TaskSnapshotSurface.java | 13 +--------- .../com/android/server/wm/WindowAnimator.java | 20 ++++++-------- .../com/android/server/wm/WindowState.java | 26 ++++++++++++++----- 5 files changed, 39 insertions(+), 31 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowAnimator.java b/services/core/java/com/android/server/wm/AppWindowAnimator.java index 16edd35137fbe..65e3ec015bc6d 100644 --- a/services/core/java/com/android/server/wm/AppWindowAnimator.java +++ b/services/core/java/com/android/server/wm/AppWindowAnimator.java @@ -411,7 +411,9 @@ public class AppWindowAnimator { } if (DEBUG_ANIM) Slog.v(TAG, "Animation done in " + mAppToken - + ": reportedVisible=" + mAppToken.reportedVisible); + + ": reportedVisible=" + mAppToken.reportedVisible + + " okToDisplay=" + mService.okToDisplay() + + " startingDisplayed=" + mAppToken.startingDisplayed); transformation.clear(); diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 257f2856213e2..bbf7d9ff8a52d 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -520,9 +520,16 @@ class DisplayContent extends WindowContainer implements WindowManagerP boolean mHidden; // Used to determine if to show child windows. boolean mWallpaperVisible; // for wallpaper, what was last vis report? private boolean mDragResizing; - private boolean mDragResizingChangeReported; + private boolean mDragResizingChangeReported = true; private int mResizeMode; private RemoteCallbackList mFocusCallbacks; @@ -1155,11 +1155,7 @@ class WindowState extends WindowContainer implements WindowManagerP return; } - mLastOverscanInsets.set(mOverscanInsets); - mLastContentInsets.set(mContentInsets); - mLastVisibleInsets.set(mVisibleInsets); - mLastStableInsets.set(mStableInsets); - mLastOutsets.set(mOutsets); + updateLastInsetValues(); mService.makeWindowFreezingScreenIfNeededLocked(this); // If the orientation is changing, or we're starting or ending a drag resizing action, @@ -4404,6 +4400,24 @@ class WindowState extends WindowContainer implements WindowManagerP return result; } + /** + * @return True if this window has been laid out at least once; false otherwise. + */ + boolean isLaidOut() { + return mLayoutSeq != -1; + } + + /** + * Updates the last inset values to the current ones. + */ + void updateLastInsetValues() { + mLastOverscanInsets.set(mOverscanInsets); + mLastContentInsets.set(mContentInsets); + mLastVisibleInsets.set(mVisibleInsets); + mLastStableInsets.set(mStableInsets); + mLastOutsets.set(mOutsets); + } + // TODO: Hack to work around the number of states AppWindowToken needs to access without having // access to its windows children. Need to investigate re-writing // {@link AppWindowToken#updateReportedVisibilityLocked} so this can be removed.