From fa61c1f571a831eff0ff9f132694da1c66b67f2c Mon Sep 17 00:00:00 2001 From: Chris Li Date: Thu, 20 Jul 2023 16:47:20 +0800 Subject: [PATCH] Fix Invalid Surface error This is only used for legacy transition, so change it to an error log to fix the flakiness. Bug: 242718321 Test: pass existing tests. Merged-In: Ib2a68f7488724370e44da28bdc30c8db19085889 Change-Id: Ib2a68f7488724370e44da28bdc30c8db19085889 --- .../android/server/wm/SurfaceAnimationRunner.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java index 1ae7816ecd246..b93dbceef0155 100644 --- a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java +++ b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java @@ -62,6 +62,8 @@ import java.util.function.Supplier; */ class SurfaceAnimationRunner { + private static final String TAG = SurfaceAnimationRunner.class.getSimpleName(); + private final Object mLock = new Object(); /** @@ -185,6 +187,16 @@ class SurfaceAnimationRunner { // We must wait for t to be committed since otherwise the leash doesn't have the // windows we want to screenshot and extend as children. t.addTransactionCommittedListener(mEdgeExtensionExecutor, () -> { + if (!animationLeash.isValid()) { + Log.e(TAG, "Animation leash is not valid"); + synchronized (mEdgeExtensionLock) { + mEdgeExtensions.remove(animationLeash); + } + synchronized (mLock) { + mPreProcessingAnimations.remove(animationLeash); + } + return; + } final WindowAnimationSpec animationSpec = a.asWindowAnimationSpec(); final Transaction edgeExtensionCreationTransaction = new Transaction(); @@ -449,8 +461,7 @@ class SurfaceAnimationRunner { // The leash we are trying to screenshot may have been removed by this point, which is // likely the reason for ending up with a null edgeBuffer, in which case we just want to // return and do nothing. - Log.e("SurfaceAnimationRunner", "Failed to create edge extension - " - + "edge buffer is null"); + Log.e(TAG, "Failed to create edge extension - edge buffer is null"); return; }