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

Commit aa02d1b4 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Make leash cleanup on-demand instead of default.

For some reason, Launcher still has performance regressions if we
always do this. I'm not sure why that is, but I don't have the
bandwidth to investigate right now. Since the change was to avoid a
leak when using the Animation library in the first place, we add an
explicit parameter that is false by default so we can limit the
behavior change to the library.

Bug: 403833923
Flag: EXEMPT bugfix
Test: manual
Change-Id: Iec8e107ff5fa05d3ab7f353218985b6eba26d817
parent 09782e97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -827,7 +827,7 @@ constructor(

    /** [Runner] wrapper that supports animation takeovers. */
    private inner class OriginTransition(private val runner: Runner) : IRemoteTransition {
        private val delegate = RemoteAnimationRunnerCompat.wrap(runner)
        private val delegate = RemoteAnimationRunnerCompat.wrap(runner, true)

        init {
            assertLongLivedReturnAnimations()
+16 −5
Original line number Diff line number Diff line
@@ -79,6 +79,15 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner

    /** Wraps a remote animation runner in a remote-transition. */
    public static RemoteTransitionStub wrap(IRemoteAnimationRunner runner) {
        return wrap(runner, false);
    }

    /**
     * Wraps a remote animation runner in a remote-transition, optionally reparenting the transition
     * leashes to null to explicitly clean them up once the animation is finished.
     */
    public static RemoteTransitionStub wrap(
            IRemoteAnimationRunner runner, boolean reparentLeashesOnFinish) {
        return new RemoteTransitionStub() {
            final ArrayMap<IBinder, Runnable> mFinishRunnables = new ArrayMap<>();

@@ -198,6 +207,7 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
                    // before GC would.
                    info.releaseAllSurfaces();
                    // Make sure that the transition leashes created are not leaked.
                    if (reparentLeashesOnFinish) {
                        for (SurfaceControl leash : leashMap.values()) {
                            try {
                                finishTransaction.reparent(leash, null);
@@ -205,6 +215,7 @@ public abstract class RemoteAnimationRunnerCompat extends IRemoteAnimationRunner
                                Log.e(TAG, "Failed to reparent leash", e);
                            }
                        }
                    }
                    // Don't release here since launcher might still be using them. Instead
                    // let launcher release them (eg. via RemoteAnimationTargets)
                    leashMap.clear();