RESTRICT AUTOMERGE - 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
(cherry picked from commit b4727e0f55)
This commit is contained in:
Robert Carr
2020-02-21 12:04:31 -08:00
committed by Valerie Hau
parent 14ebab3b19
commit 6d16c8c340
3 changed files with 22 additions and 10 deletions

View File

@@ -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();
}

View File

@@ -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();
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;

View File

@@ -322,7 +322,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
@@ -9639,4 +9639,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;
}
}