Commit 4fb651b1 by andrewlewis Committed by christosts

Instantiate `SurfaceView` on main thread

On some devices/builds it seems that the `SurfaceView` constructor tries to create a handler. Move instantiation to the main thread when getting the debug surface view so that handler creation succeeds.

PiperOrigin-RevId: 505745387
parent ff56b7d2
......@@ -737,9 +737,9 @@ public final class TransformerActivity extends AppCompatActivity {
// Update the UI on the main thread and wait for the output surface to be available.
CountDownLatch surfaceCreatedCountDownLatch = new CountDownLatch(1);
SurfaceView surfaceView = new SurfaceView(/* context= */ TransformerActivity.this);
runOnUiThread(
() -> {
surfaceView = new SurfaceView(/* context= */ TransformerActivity.this);
AspectRatioFrameLayout debugFrame = checkNotNull(TransformerActivity.this.debugFrame);
debugFrame.addView(surfaceView);
debugFrame.setAspectRatio((float) width / height);
......@@ -771,7 +771,6 @@ public final class TransformerActivity extends AppCompatActivity {
Thread.currentThread().interrupt();
return null;
}
this.surfaceView = surfaceView;
return surfaceView;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment