From 9385a91063a1df24ee7a06350c8451891cf6a274 Mon Sep 17 00:00:00 2001 From: Pablo Gamito Date: Tue, 5 Apr 2022 15:52:47 +0000 Subject: [PATCH] Create a new Transaction to apply the edge extensions mFrameTransaction is not thread safe and should only be used in the animation thread, but here we were accessing this transaction in a binder thread through the TransactionCommittedListenerCallback. Bug: 228000332 Test: atest CtsWindowManagerDeviceTestCases:ActivityTransitionTests Change-Id: Ia5c5022ebd1a12f45fecbb80905606dbda85caf9 --- .../android/server/wm/SurfaceAnimationRunner.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java index 65dca86d02599..83be73a47eb4f 100644 --- a/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java +++ b/services/core/java/com/android/server/wm/SurfaceAnimationRunner.java @@ -176,13 +176,24 @@ class SurfaceAnimationRunner { t.addTransactionCommittedListener(Runnable::run, () -> { final WindowAnimationSpec animationSpec = a.asWindowAnimationSpec(); + final Transaction edgeExtensionCreationTransaction = new Transaction(); edgeExtendWindow(animationLeash, animationSpec.getRootTaskBounds(), animationSpec.getAnimation(), - mFrameTransaction); + edgeExtensionCreationTransaction); synchronized (mLock) { // only run if animation is not yet canceled by this point if (mPreProcessingAnimations.get(animationLeash) == runningAnim) { + // In the case the animation is cancelled, edge extensions are removed + // onAnimationLeashLost which is called before onAnimationCancelled. + // So we need to check if the edge extensions have already been removed + // or not, and if so we don't want to apply the transaction. + synchronized (mEdgeExtensionLock) { + if (!mEdgeExtensions.isEmpty()) { + edgeExtensionCreationTransaction.apply(); + } + } + mPreProcessingAnimations.remove(animationLeash); mPendingAnimations.put(animationLeash, runningAnim); if (!mAnimationStartDeferred) {