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

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

Explicitly disable BLAST for SurfaceControlViewHost surfaces

Right now it crashes because the ViewRoot expects to receive a
BLAST surface but the WindowlessWindowManager doesn't support it.
Adding support should be relatively trivial (coming in a follow-up)
but we haven't tested it yet so suggesting merging this patch for
today.

Bug: 150000636
Test: Existing tests pass
Change-Id: I4b36d190c8f4f022dada656e02452034113a4000
parent 0c963a3a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class SurfaceControlViewHost {
            @NonNull WindowlessWindowManager wwm) {
        mWm = wwm;
        mViewRoot = new ViewRootImpl(c, d, mWm);
        mViewRoot.forceDisableBLAST();
        mAccessibilityEmbeddedConnection = mViewRoot.getAccessibilityEmbeddedConnection();
    }

@@ -135,6 +136,7 @@ public class SurfaceControlViewHost {
        mWm = new WindowlessWindowManager(context.getResources().getConfiguration(),
                mSurfaceControl, hostToken);
        mViewRoot = new ViewRootImpl(context, display, mWm);
        mViewRoot.forceDisableBLAST();
        mAccessibilityEmbeddedConnection = mViewRoot.getAccessibilityEmbeddedConnection();
    }

+7 −9
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                 * This gets called on a RenderThread worker thread, so members accessed here must
                 * be protected by a lock.
                 */
                final boolean useBLAST = WindowManagerGlobal.useBLAST();
                final boolean useBLAST = viewRoot.useBLAST();
                viewRoot.registerRtFrameCallback(frame -> {
                    try {
                        final SurfaceControl.Transaction t = useBLAST ?
@@ -930,7 +930,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                                    mSurfaceHeight);
                        }
                    } else if ((layoutSizeChanged || positionChanged) &&
                            WindowManagerGlobal.useBLAST()) {
                            viewRoot.useBLAST()) {
                        viewRoot.setUseBLASTSyncTransaction();
                    }
                    mTmpTransaction.setCornerRadius(mSurfaceControl, mCornerRadius);
@@ -1132,9 +1132,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall

    private void applySurfaceTransforms(SurfaceControl surface, SurfaceControl.Transaction t,
            Rect position, long frameNumber) {
        if (frameNumber > 0 && !WindowManagerGlobal.useBLAST()) {
        final ViewRootImpl viewRoot = getViewRootImpl();

        if (frameNumber > 0 && viewRoot != null && !viewRoot.useBLAST()) {
            t.deferTransactionUntil(surface, viewRoot.getRenderSurfaceControl(),
                    frameNumber);
        }
@@ -1150,8 +1149,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    }

    private void setParentSpaceRectangle(Rect position, long frameNumber) {
        final boolean useBLAST = WindowManagerGlobal.useBLAST();
        final ViewRootImpl viewRoot = getViewRootImpl();
        final boolean useBLAST = viewRoot.useBLAST();
        final SurfaceControl.Transaction t = useBLAST ? viewRoot.getBLASTSyncTransaction() :
            mRtTransaction;

@@ -1211,7 +1210,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall

        @Override
        public void positionLost(long frameNumber) {
            boolean useBLAST = WindowManagerGlobal.useBLAST();
            final ViewRootImpl viewRoot = getViewRootImpl();
            boolean useBLAST = viewRoot != null && viewRoot.useBLAST();
            if (DEBUG) {
                Log.d(TAG, String.format("%d windowPositionLost, frameNr = %d",
                        System.identityHashCode(this), frameNumber));
@@ -1222,8 +1222,6 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
                return;
            }

            final ViewRootImpl viewRoot = getViewRootImpl();

            final SurfaceControl.Transaction t = useBLAST ?
                (viewRoot != null ? viewRoot.getBLASTSyncTransaction() : mRtTransaction) :
                mRtTransaction;
+13 −1
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ public final class ViewRootImpl implements ViewParent,
     */
    private boolean mForceNextConfigUpdate;

    private final boolean mUseBLASTAdapter;
    private boolean mUseBLASTAdapter;

    /**
     * Signals that compatibility booleans have been initialized according to
@@ -9627,4 +9627,16 @@ public final class ViewRootImpl implements ViewParent,
    public void onDescendantUnbufferedRequested() {
        mUnbufferedInputSource = mView.mUnbufferedInputSource;
    }

    /**
     * Force disabling use of the BLAST adapter regardless of the system
     * flag. Needs to be called before addView.
     */
    void forceDisableBLAST() {
        mUseBLASTAdapter = false;
    }

    boolean useBLAST() {
        return mUseBLASTAdapter;
    }
}