Commit 2a127f5b authored by Klaus Weidner's avatar Klaus Weidner Committed by Chromium LUCI CQ

WebXR: Disable SurfaceControl for AR DOM Overlay

This works around issues where using the screen keyboard (IME) during a
WebXR AR session with DOM Overlay active left the compositor view in a
confused state with SurfaceControl active. Keep SurfaceControl disabled
for the duration of the session, and recreate the SurfaceManager at
session exit.

Bug: 1166248
Change-Id: I7f816ab0cfec40e316998c7c94ea6973d2d57826
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631470Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Klaus Weidner <klausw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844258}
parent b052ff19
...@@ -77,7 +77,9 @@ public class CompositorView ...@@ -77,7 +77,9 @@ public class CompositorView
private boolean mPreloadedResources; private boolean mPreloadedResources;
private List<Runnable> mDrawingFinishedCallbacks; private List<Runnable> mDrawingFinishedCallbacks;
private boolean mIsInVr; // True while the compositor view is in VR Browser mode (obsolescent), or in a WebXR
// "immersive-ar" session with DOM Overlay enabled. This disables SurfaceControl while active.
private boolean mIsInXr;
private boolean mIsSurfaceControlEnabled; private boolean mIsSurfaceControlEnabled;
private boolean mSelectionHandlesActive; private boolean mSelectionHandlesActive;
...@@ -98,7 +100,7 @@ public class CompositorView ...@@ -98,7 +100,7 @@ public class CompositorView
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF) if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)
&& mCompositorSurfaceManager != null && !mIsInVr && mCompositorSurfaceManager != null && !mIsInXr
&& mNativeCompositorView != 0) { && mNativeCompositorView != 0) {
mCompositorSurfaceManager.shutDown(); mCompositorSurfaceManager.shutDown();
createCompositorSurfaceManager(); createCompositorSurfaceManager();
...@@ -208,7 +210,7 @@ public class CompositorView ...@@ -208,7 +210,7 @@ public class CompositorView
public void onSelectionHandlesStateChanged(boolean active) { public void onSelectionHandlesStateChanged(boolean active) {
// If the feature is disabled or we're in Vr mode, we are already rendering directly to the // If the feature is disabled or we're in Vr mode, we are already rendering directly to the
// SurfaceView. // SurfaceView.
if (!mIsSurfaceControlEnabled || mIsInVr) return; if (!mIsSurfaceControlEnabled || mIsInXr) return;
if (mSelectionHandlesActive == active) return; if (mSelectionHandlesActive == active) return;
mSelectionHandlesActive = active; mSelectionHandlesActive = active;
...@@ -340,20 +342,20 @@ public class CompositorView ...@@ -340,20 +342,20 @@ public class CompositorView
* @param enabled Whether to enter or leave overlay immersive ar mode. * @param enabled Whether to enter or leave overlay immersive ar mode.
*/ */
public void setOverlayImmersiveArMode(boolean enabled) { public void setOverlayImmersiveArMode(boolean enabled) {
// In SurfaceControl mode, we don't need to switch surfaces for the compositor, we can // Disable SurfaceControl for the duration of the session. This works around a black
// continue using its already-translucent surface. (The ArImmersiveOverlay has its own // screen after activating the screen keyboard (IME), see https://crbug.com/1166248.
// separate opaque surface which is used for displaying the camera image and WebGL drawn mIsInXr = enabled;
// content. The compositor surface appears on top of that as an overlay.)
// TODO(https://crbug.com/1122103): revisit once the stale-ChromeChildSurface issue is
// fixed.
if (!canUseSurfaceControl()
|| mCompositorSurfaceManager.getFormatOfOwnedSurface() != PixelFormat.TRANSLUCENT) {
// If SurfaceControl is off, or if we haven't started using it yet, switch the
// compositor to a translucent surface, same as overlay video mode.
setOverlayVideoMode(enabled); setOverlayVideoMode(enabled);
}
CompositorViewJni.get().setOverlayImmersiveArMode( CompositorViewJni.get().setOverlayImmersiveArMode(
mNativeCompositorView, CompositorView.this, enabled); mNativeCompositorView, CompositorView.this, enabled);
if (!enabled) {
// Exiting AR mode leaves SurfaceControl in a confused state if the screen keyboard
// (IME) was activated, see https://crbug.com/1166248. Reset the surface manager
// at session exit to work around this.
mCompositorSurfaceManager.shutDown();
createCompositorSurfaceManager();
}
} }
private int getSurfacePixelFormat() { private int getSurfacePixelFormat() {
...@@ -376,7 +378,7 @@ public class CompositorView ...@@ -376,7 +378,7 @@ public class CompositorView
} }
private boolean canUseSurfaceControl() { private boolean canUseSurfaceControl() {
return !mIsInVr && !mSelectionHandlesActive; return !mIsInXr && !mSelectionHandlesActive;
} }
@Override @Override
...@@ -601,7 +603,7 @@ public class CompositorView ...@@ -601,7 +603,7 @@ public class CompositorView
*/ */
public void replaceSurfaceManagerForVr( public void replaceSurfaceManagerForVr(
CompositorSurfaceManager vrCompositorSurfaceManager, WindowAndroid window) { CompositorSurfaceManager vrCompositorSurfaceManager, WindowAndroid window) {
mIsInVr = true; mIsInXr = true;
mCompositorSurfaceManager.shutDown(); mCompositorSurfaceManager.shutDown();
CompositorViewJni.get().setCompositorWindow( CompositorViewJni.get().setCompositorWindow(
...@@ -619,7 +621,7 @@ public class CompositorView ...@@ -619,7 +621,7 @@ public class CompositorView
* @param windowToRestore The non-VR WindowAndroid to restore. * @param windowToRestore The non-VR WindowAndroid to restore.
*/ */
public void onExitVr(WindowAndroid windowToRestore) { public void onExitVr(WindowAndroid windowToRestore) {
mIsInVr = false; mIsInXr = false;
if (mNativeCompositorView == 0) return; if (mNativeCompositorView == 0) return;
setWindowAndroid(windowToRestore); setWindowAndroid(windowToRestore);
......
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 to comment