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

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

Intercept NPE in ActivityTransitionAnimator.

Note that the actual NPE happens inside GhostView extremely rarely
and I could never reproduce it. Regardless, it's better to avoid
crashing since there currently doesn't seem to be a path to prevent
it.

Fix: 402737819
Flag: EXEMPT crash prevention only
Test: manual
Change-Id: If7f97c9aeac2ceeac5218855ca7f6397efff9207
parent 09558664
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ constructor(
            ViewTransitionRegistry.instance
        } else {
            null
        }
        },
) : ActivityTransitionAnimator.Controller {
    override val isLaunching: Boolean = true

@@ -313,9 +313,17 @@ constructor(
        // visibility that is saved by `setShouldBlockVisibilityChanges()` for a later restoration.
        (ghostedView as? LaunchableView)?.setShouldBlockVisibilityChanges(true)

        // Create a ghost of the view that will be moving and fading out. This allows to fade out
        // the content before fading out the background.
        try {
            // Create a ghost of the view that will be moving and fading out. This allows to fade
            // out the content before fading out the background.
            ghostView = GhostView.addGhost(ghostedView, transitionContainer)
        } catch (e: Exception) {
            // It is not 100% clear what conditions cause this exception to happen in practice, and
            // we could never reproduce it, but it does show up extremely rarely. We already handle
            // the scenario where ghostView is null, so we just avoid crashing and log the error.
            // See b/315858472 for an investigation of the issue.
            Log.e(TAG, "Failed to create ghostView", e)
        }

        // [GhostView.addGhost], the result of which is our [ghostView], creates a [GhostView], and
        // adds it first to a [FrameLayout] container. It then adds _that_ container to an