From af0d6d26d172716e31f3ea7a12169ea39ac8e905 Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Fri, 8 Jun 2018 15:25:35 +0200 Subject: [PATCH] Prevent showing windows while animating to avoid color mode switch If we switch the color mode during a transition, it's pretty much guaranteed that SF is going to jank. To work around that, we disallow showing the real content while an activity with a non-standard-color mode is animating. Test: Reopen photos, observe no jank Bug: 79878256 Change-Id: Id27db483844d9424ccfb9afdebd31325eae0cdd8 --- .../com/android/server/wm/AppWindowToken.java | 20 ++++++++++++++++++- .../com/android/server/wm/DisplayContent.java | 2 +- .../server/wm/WindowStateAnimator.java | 5 +++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 08d0ae9dcdd88..fa6079c51906e 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -19,6 +19,7 @@ package com.android.server.wm; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; +import static android.content.pm.ActivityInfo.COLOR_MODE_DEFAULT; import static android.content.pm.ActivityInfo.CONFIG_ORIENTATION; import static android.content.pm.ActivityInfo.CONFIG_SCREEN_SIZE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; @@ -1377,7 +1378,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree setAppLayoutChanges(FINISH_LAYOUT_REDO_ANIM, "checkAppWindowsReadyToShow"); // We can now show all of the drawn windows! - if (!mService.mOpeningApps.contains(this)) { + if (!mService.mOpeningApps.contains(this) && canShowWindows()) { showAllWindowsLocked(); } } @@ -2270,4 +2271,21 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree boolean isClosingOrEnteringPip() { return (isAnimating() && hiddenRequested) || mWillCloseOrEnterPip; } + + /** + * @return Whether we are allowed to show non-starting windows at the moment. We disallow + * showing windows during transitions in case we have windows that have wide-color-gamut + * color mode set to avoid jank in the middle of the transition. + */ + boolean canShowWindows() { + return allDrawn && !(isReallyAnimating() && hasNonDefaultColorWindow()); + } + + /** + * @return true if we have a window that has a non-default color mode set; false otherwise. + */ + private boolean hasNonDefaultColorWindow() { + return forAllWindows(ws -> ws.mAttrs.getColorMode() != COLOR_MODE_DEFAULT, + true /* topToBottom */); + } } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index cfbcd176eaf49..47dbccb9a2028 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -404,7 +404,7 @@ class DisplayContent extends WindowContainer