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

Commit c34aea87 authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceView: Check ViewRootImpl non-null

This call to updateRelativeZ may be triggered from the
RT frame callback which may be triggered after we are detached
from the Window and in that case will be null. If we are detached
we are also going invisible so there is no need
to set a relativeZ.

Bug: 158706756
Test: Existing tests pass
Change-Id: I46aa824807b7b275e6a015c428fe7467a72ca949
parent 55c4e431
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -1638,9 +1638,14 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    }

    private void updateRelativeZ(Transaction t) {
        SurfaceControl viewRoot = getViewRootImpl().getSurfaceControl();
        t.setRelativeLayer(mBackgroundControl, viewRoot, Integer.MIN_VALUE);
        t.setRelativeLayer(mSurfaceControl, viewRoot, mSubLayer);
        final ViewRootImpl viewRoot = getViewRootImpl();
        if (viewRoot == null) {
            // We were just detached.
            return;
        }
        final SurfaceControl viewRootControl = viewRoot.getSurfaceControl();
        t.setRelativeLayer(mBackgroundControl, viewRootControl, Integer.MIN_VALUE);
        t.setRelativeLayer(mSurfaceControl, viewRootControl, mSubLayer);
    }

    /**