From 4a2d3741358cd4efa6373b43c208de5236441120 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Mon, 11 Feb 2019 12:15:38 -0800 Subject: [PATCH] Postpone destroying leash until after cancel callback. Currently we may end up releasing the leash (via Transaction#remove) before setting mCancelled on the animation. This means if another frame executes we could attempt to use a released surface. Here we cancel before releasing the surface, careful not to disturb other logic. Bug: 124112773 Test: Fixes them allegedly Change-Id: I920a1c8f891a5cdc53b1d55298f661abc91b3259 --- .../core/java/com/android/server/wm/SurfaceAnimator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/SurfaceAnimator.java b/services/core/java/com/android/server/wm/SurfaceAnimator.java index 5ea24518370bc..35b8641371be3 100644 --- a/services/core/java/com/android/server/wm/SurfaceAnimator.java +++ b/services/core/java/com/android/server/wm/SurfaceAnimator.java @@ -251,7 +251,7 @@ class SurfaceAnimator { if (DEBUG_ANIM) Slog.i(TAG, "Cancelling animation restarting=" + restarting); final SurfaceControl leash = mLeash; final AnimationAdapter animation = mAnimation; - reset(t, forwardCancel); + reset(t, false); if (animation != null) { if (!mAnimationStartDelayed && forwardCancel) { animation.onAnimationCancelled(leash); @@ -260,6 +260,12 @@ class SurfaceAnimator { mAnimationFinishedCallback.run(); } } + + if (forwardCancel && leash != null) { + t.remove(leash); + mService.scheduleAnimationLocked(); + } + if (!restarting) { mAnimationStartDelayed = false; }