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

Commit 58510fe4 authored by Luca Zuccarini's avatar Luca Zuccarini Committed by Android (Google) Code Review
Browse files

Merge "Clean up the reparented leash at the end of the transition." into main

parents 055fdafb a2454527
Loading
Loading
Loading
Loading
+19 −2
Original line number Original line Diff line number Diff line
@@ -1562,8 +1562,7 @@ constructor(
                            // TODO(b/397180418): re-use the start transaction once the
                            // TODO(b/397180418): re-use the start transaction once the
                            //  RemoteAnimation wrapper is cleaned up.
                            //  RemoteAnimation wrapper is cleaned up.
                            SurfaceControl.Transaction().use {
                            SurfaceControl.Transaction().use {
                                it.reparent(window.leash, viewRoot.surfaceControl)
                                it.reparent(window.leash, viewRoot.surfaceControl).apply()
                                it.apply()
                            }
                            }
                        }
                        }


@@ -1586,6 +1585,24 @@ constructor(
                        listener?.onTransitionAnimationEnd()
                        listener?.onTransitionAnimationEnd()
                        iCallback?.invoke()
                        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) {
                        if (DEBUG_TRANSITION_ANIMATION) {
                            Log.d(
                            Log.d(
                                TAG,
                                TAG,