From 6a8af5a68916f3fe507e0f5b6e553b8e68e601d8 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Thu, 1 Dec 2022 22:33:41 -0600 Subject: [PATCH] Skip immediate hiding from finishTransition It was used to solve flickering issues when dismissing split screen and toggling pip without transition (commit 6914f08). But since most of visibility changes are associated with transition, and there is new synchronization mechanism of transaction. The immediate hiding also doesn't make visual difference in legacy transition. Typically, if the visibility is changed, it will schedule to call prepareSurface, which will update surface visibility according to isVisible(). This may reduce the latency to Activity#dispatchEnterAnimationComplete. Also - Initialize ActivityRecord surface as invisible so it doesn't need to update by hide() in the first prepareSurface(). - Remove unused method onSurfaceShown. Bug: 260059642 Test: FilesAppPerfTest#testFilesColdStartPerformance Change-Id: Icc9efecf2f078857a448f1cbeb85c865c6c8d401 --- .../java/com/android/server/wm/ActivityRecord.java | 10 ++++++++-- .../java/com/android/server/wm/WindowContainer.java | 8 -------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 66992aa79fc27..e6a99b2d1ea5e 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -671,7 +671,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A private boolean mCurrentLaunchCanTurnScreenOn = true; /** Whether our surface was set to be showing in the last call to {@link #prepareSurfaces} */ - private boolean mLastSurfaceShowing = true; + private boolean mLastSurfaceShowing; /** * The activity is opaque and fills the entire space of this task. @@ -5495,7 +5495,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // no animation but there will still be a transition set. // We still need to delay hiding the surface such that it // can be synchronized with showing the next surface in the transition. - if (!isVisible() && !delayed && !displayContent.mAppTransition.isTransitionSet()) { + if (!usingShellTransitions && !isVisible() && !delayed + && !displayContent.mAppTransition.isTransitionSet()) { SurfaceControl.openTransaction(); try { forAllWindows(win -> { @@ -7433,6 +7434,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } } + @Override + boolean showSurfaceOnCreation() { + return false; + } + @Override void prepareSurfaces() { final boolean show = isVisible() || isAnimating(PARENTS, diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 80357eb0c7faa..c37edc2309f98 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -635,7 +635,6 @@ class WindowContainer extends ConfigurationContainer< if (showSurfaceOnCreation()) { getSyncTransaction().show(mSurfaceControl); } - onSurfaceShown(getSyncTransaction()); updateSurfacePositionNonOrganized(); } @@ -687,13 +686,6 @@ class WindowContainer extends ConfigurationContainer< scheduleAnimation(); } - /** - * Called when the surface is shown for the first time. - */ - void onSurfaceShown(Transaction t) { - // do nothing - } - // Temp. holders for a chain of containers we are currently processing. private final LinkedList mTmpChain1 = new LinkedList<>(); private final LinkedList mTmpChain2 = new LinkedList<>();