From db2f6e6edf864d17e53d48e62c4b4d04529e4081 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Wed, 1 Mar 2017 20:17:58 -0800 Subject: [PATCH] Don't destroy preserved surfaces when cleaning up on resume. We clean up surfaces from apps which were stopping (mDestroying=true) but not stopped when we resume, as described in commit 45e6d2d. The removal of preserved surfaces was added earlier in eb66557 for a use case where an app is stopped without an animation pass. It seems the clean up of preserved surfaces on resume may be more coincidental than intentional, so let's try disabling it! This fixes flicker at the end of the PiP animation when we use preserved surfaces for switching in to fullscreen. Bug: 35396882 Test: Move PiP to fullscreen. No flickers? Change-Id: I0df55b11774c826027b0982fca7a28f4d8322d1d --- .../com/android/server/wm/WindowState.java | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index b9466d2d43d05..d3519fa2ba483 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2721,29 +2721,32 @@ class WindowState extends WindowContainer implements WindowManagerP destroyedSomething |= c.destroySurface(cleanupOnResume, appStopped); } - if (appStopped || mWindowRemovalAllowed || cleanupOnResume) { - - mWinAnimator.destroyPreservedSurfaceLocked(); - - if (mDestroying) { - if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + this - + " destroySurfaces: appStopped=" + appStopped - + " win.mWindowRemovalAllowed=" + mWindowRemovalAllowed - + " win.mRemoveOnExit=" + mRemoveOnExit); - - if (!cleanupOnResume || mRemoveOnExit) { - destroyOrSaveSurface(); - } - if (mRemoveOnExit) { - removeImmediately(); - } - if (cleanupOnResume) { - requestUpdateWallpaperIfNeeded(); - } - mDestroying = false; - destroyedSomething = true; - } + if (!(appStopped || mWindowRemovalAllowed || cleanupOnResume)) { + return destroyedSomething; } + + if (appStopped || mWindowRemovalAllowed) { + mWinAnimator.destroyPreservedSurfaceLocked(); + } + + if (mDestroying) { + if (DEBUG_ADD_REMOVE) Slog.e(TAG_WM, "win=" + this + + " destroySurfaces: appStopped=" + appStopped + + " win.mWindowRemovalAllowed=" + mWindowRemovalAllowed + + " win.mRemoveOnExit=" + mRemoveOnExit); + if (!cleanupOnResume || mRemoveOnExit) { + destroyOrSaveSurface(); + } + if (mRemoveOnExit) { + removeImmediately(); + } + if (cleanupOnResume) { + requestUpdateWallpaperIfNeeded(); + } + mDestroying = false; + destroyedSomething = true; + } + return destroyedSomething; } @@ -4401,7 +4404,8 @@ class WindowState extends WindowContainer implements WindowManagerP // will keep their surface and its size may change over time. if (mHasSurface && !isChildWindow()) { mWinAnimator.preserveSurfaceLocked(); - result |= RELAYOUT_RES_FIRST_TIME; + result |= RELAYOUT_RES_SURFACE_CHANGED | + RELAYOUT_RES_FIRST_TIME; } } final boolean freeformResizing = isDragResizing()