Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ae2c3a3 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Avoid prematurely reporting completion of split resize transition

For example, when there is a split screen resize transition:
 SplitScreenTransitions#playResizeAnimation
 -> SplitDecorManager#onResized -> fadeOutDecor
 -> mFadeAnimator.cancel() -> onAnimationEnd
 -> updateCallbackStatus (mRunningAnimationCount becomes zero
    but it will increase in the following startFadeAnimation)
 -> the callback from SplitScreenTransitions#playResizeAnimation
    decor.onResized(startTransaction, animated -> {
        mAnimations.remove(va);
        if (animated) {
            // It won't post if current thread is the same.
            mTransitions.getMainExecutor().execute(() -> {
                onFinish(null /* wct */);
            });
        }
    });
 -> onFinish -> release surfaces
 -> the next iteration of playResizeAnimation's loop  uses the
    released surfaces.

Bug: 429548260
Flag: EXEMPT bugfix
Test: Set all animation scale to 5.
      Drag split screen divider multiple times in a short time.
Change-Id: I00ab9581364de296f60d94fdbe9770cc3415c608
parent 5d23bdf5
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -339,6 +339,23 @@ public class SplitDecorManager extends WindowlessWindowManager {
    /** Stops showing resizing hint. */
    public void onResized(SurfaceControl.Transaction t,
            @Nullable Consumer<Boolean> animFinishedCallback) {
        // If there is a running animation, place a placeholder callback to avoid calling the end
        // callback too early when canceling the existed animation before the new animation starts.
        final Consumer<Boolean> callbackPlaceHolder =
                animFinishedCallback != null && mRunningAnimationCount > 0 ? status -> {} : null;
        if (callbackPlaceHolder != null) {
            mRunningAnimationCount++;
            mAnimFinishCallbacks.put(callbackPlaceHolder, false);
        }
        animateResized(t, animFinishedCallback);
        if (callbackPlaceHolder != null) {
            mRunningAnimationCount--;
            updateCallbackStatus(false /* callbackStatus */, callbackPlaceHolder);
        }
    }

    private void animateResized(SurfaceControl.Transaction t,
            @Nullable Consumer<Boolean> animFinishedCallback) {
        if (mScreenshotAnimator != null && mScreenshotAnimator.isRunning()) {
            mScreenshotAnimator.cancel();
        }