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

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

Clean up the reparented leash at the end of the transition.

This is to avoid leaking leashes and only temporary until we remove
the wrapper (b/397180418). Also because of the wrapper, the
Transaction might throw (in which case the leash doesn't leak as
it's been already released) so it's best effort.

Bug: 390422470
Flag: com.android.systemui.move_transition_animation_layer
Test: atest ActivityTransitionAnimatorTest
Change-Id: I74092d1cd5ed480a37e0d1e296dc3270de56bb96
parent 94cb9e5d
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -1562,8 +1562,7 @@ constructor(
                            // TODO(b/397180418): re-use the start transaction once the
                            //  RemoteAnimation wrapper is cleaned up.
                            SurfaceControl.Transaction().use {
                                it.reparent(window.leash, viewRoot.surfaceControl)
                                it.apply()
                                it.reparent(window.leash, viewRoot.surfaceControl).apply()
                            }
                        }

@@ -1586,6 +1585,24 @@ constructor(
                        listener?.onTransitionAnimationEnd()
                        iCallback?.invoke()

                        if (reparent) {
                            // Relying on this try-catch is not great, but the existence of
                            // RemoteAnimationRunnerCompat means that we can't reliably assume that
                            // the transaction will be executed while the leash is still valid.
                            // TODO(b/397180418): remove once the RemoteAnimation wrapper is cleaned
                            //  up.
                            try {
                                // Reparent to null to avoid leaking the transition leash.
                                // TODO(b/397180418): shouldn't be needed anymore once the
                                //  RemoteAnimation wrapper is cleaned up.
                                SurfaceControl.Transaction().use {
                                    it.reparent(window.leash, null).apply()
                                }
                            } catch (e: IllegalStateException) {
                                Log.e(TAG, "Failed to clean up transition leash: already released")
                            }
                        }

                        if (DEBUG_TRANSITION_ANIMATION) {
                            Log.d(
                                TAG,