Commit ffff67f6 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add VR workarounds for early entry

Adds two workarounds for Chrome being resumed or started too early when
entering VR. These can be removed if/when the platform-side issue that
causes these issues is fixed in VrCore.

Bug: 854327, 762724
Change-Id: If9645c58e9d208a734582992aad5c85d378f5f40
Reviewed-on: https://chromium-review.googlesource.com/1112761Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570084}
parent aa4992a0
...@@ -47,6 +47,19 @@ public class VrMainActivity extends Activity { ...@@ -47,6 +47,19 @@ public class VrMainActivity extends Activity {
if (!VrShellDelegate.deviceSupportsVrLaunches() if (!VrShellDelegate.deviceSupportsVrLaunches()
|| (!hasDaydreamCategory && !VrShellDelegate.isInVrSession())) { || (!hasDaydreamCategory && !VrShellDelegate.isInVrSession())) {
// TODO(https://crbug.com/854327): Remove this workaround once the issue with
// launchInVr sometimes launching the given intent before entering VR is fixed.
if (IntentUtils.safeGetBooleanExtra(getIntent(),
VrIntentUtils.ENABLE_TEST_RELAUNCH_WORKAROUND_EXTRA, false)) {
Log.d(TAG,
"Relaunching given intent due to test workaround boolean being set.");
// Disable the workaround after the first time so we don't get into a loop
getIntent().putExtra(
VrIntentUtils.ENABLE_TEST_RELAUNCH_WORKAROUND_EXTRA, false);
VrIntentUtils.launchInVr(getIntent(), this);
finish();
return;
}
StringBuilder error = new StringBuilder("Attempted to launch Chrome into VR "); StringBuilder error = new StringBuilder("Attempted to launch Chrome into VR ");
if (!VrShellDelegate.deviceSupportsVrLaunches()) { if (!VrShellDelegate.deviceSupportsVrLaunches()) {
error.append("on a device that doesn't support Chrome in VR."); error.append("on a device that doesn't support Chrome in VR.");
......
...@@ -31,6 +31,11 @@ public class VrIntentUtils { ...@@ -31,6 +31,11 @@ public class VrIntentUtils {
// the relaunch logic does not work properly with the DON flow skipped. // the relaunch logic does not work properly with the DON flow skipped.
public static final String AVOID_RELAUNCH_EXTRA = public static final String AVOID_RELAUNCH_EXTRA =
"org.chromium.chrome.browser.vr_shell.AVOID_RELAUNCH"; "org.chromium.chrome.browser.vr_shell.AVOID_RELAUNCH";
// Tells Chrome to attempts a relaunch of the intent if it is received outside of VR and doesn't
// have the Daydream category set. This is a workaround for https://crbug.com/854327 where
// launchInVr can sometimes launch the given intent before entering VR.
public static final String ENABLE_TEST_RELAUNCH_WORKAROUND_EXTRA =
"org.chromium.chrome.browser.vr_shell.ENABLE_TEST_RELUANCH_WORKAROUND";
static final String VR_FRE_INTENT_EXTRA = "org.chromium.chrome.browser.vr_shell.VR_FRE"; static final String VR_FRE_INTENT_EXTRA = "org.chromium.chrome.browser.vr_shell.VR_FRE";
static final String VR_FRE_CALLER_INTENT_EXTRA = static final String VR_FRE_CALLER_INTENT_EXTRA =
......
...@@ -96,9 +96,12 @@ public class TransitionUtils { ...@@ -96,9 +96,12 @@ public class TransitionUtils {
* to errors, e.g. if there's dialog in the center of the screen blocking the canvas. * to errors, e.g. if there's dialog in the center of the screen blocking the canvas.
* *
* Only meant to be used alongside the test framework from VrTestFramework. * Only meant to be used alongside the test framework from VrTestFramework.
* @param cvc The ContentViewCore for the tab the canvas is in. * @param webContents The WebContents for the tab the canvas is in.
*/ */
public static void enterPresentation(WebContents webContents) { public static void enterPresentation(WebContents webContents) {
// TODO(https://crbug.com/762724): Remove this workaround when the issue with being resumed
// before receiving the VR broadcast is fixed on VrCore's end.
VrShellDelegateUtils.getDelegateInstance().setExpectingBroadcast();
try { try {
DOMUtils.clickNode(webContents, "webgl-canvas", false /* goThroughRootAndroidView */); DOMUtils.clickNode(webContents, "webgl-canvas", false /* goThroughRootAndroidView */);
} catch (InterruptedException | TimeoutException e) { } catch (InterruptedException | TimeoutException e) {
...@@ -208,6 +211,10 @@ public class TransitionUtils { ...@@ -208,6 +211,10 @@ public class TransitionUtils {
} }
if (avoidRelaunch) intent.putExtra(VrIntentUtils.AVOID_RELAUNCH_EXTRA, true); if (avoidRelaunch) intent.putExtra(VrIntentUtils.AVOID_RELAUNCH_EXTRA, true);
// TODO(https://crbug.com/854327): Remove this workaround once the issue with launchInVr
// sometimes launching the given intent before entering VR is fixed.
intent.putExtra(VrIntentUtils.ENABLE_TEST_RELAUNCH_WORKAROUND_EXTRA, true);
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
public void run() { public void run() {
......
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