VR: Don't wait for window mode to change before entering VR.
VrShellImpl no longer cares which orientation it's in when it's created, so we can make our VR startup synchronous and fix some bugs caused by the waiting for window mode changes. Bug: 756052 Change-Id: I40dcb76e1c66981ade934d106c1e3520918abb06 Reviewed-on: https://chromium-review.googlesource.com/667926 Reviewed-by: Yash Malik <ymalik@chromium.org> Commit-Queue: Michael Thiessen <mthiesse@chromium.org> Cr-Commit-Position: refs/heads/master@{#502333}
This commit is contained in:

committed by
Commit Bot

parent
7e05b5d979
commit
d4d04977de
chrome/android/java/src/org/chromium/chrome/browser/vr_shell
@ -133,7 +133,6 @@ public class VrShellDelegate
|
||||
private TabModelSelector mTabModelSelector;
|
||||
|
||||
private boolean mInVr;
|
||||
private final Handler mEnterVrHandler;
|
||||
private final Handler mExpectPauseOrDonSucceeded;
|
||||
private boolean mProbablyInDon;
|
||||
private boolean mNeedsAnimationCancel;
|
||||
@ -553,7 +552,6 @@ public class VrShellDelegate
|
||||
updateVrSupportLevel(null);
|
||||
mNativeVrShellDelegate = nativeInit();
|
||||
mFeedbackFrequency = VrFeedbackStatus.getFeedbackFrequency();
|
||||
mEnterVrHandler = new Handler();
|
||||
mExpectPauseOrDonSucceeded = new Handler();
|
||||
ApplicationStatus.registerStateListenerForAllActivities(this);
|
||||
if (!mPaused) onResume();
|
||||
@ -711,34 +709,8 @@ public class VrShellDelegate
|
||||
return;
|
||||
}
|
||||
mVrClassesWrapper.setVrModeEnabled(mActivity, true);
|
||||
if (!isWindowModeCorrectForVr()) {
|
||||
setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
mEnterVrHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
enterVr(tentativeWebVrMode);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
// We need to add VR UI asynchronously, or we get flashes of 2D content. Presumably this is
|
||||
// because adding the VR UI is slow and Android times out and decides to just show
|
||||
// something.
|
||||
mEnterVrHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
enterVrWithCorrectWindowMode(tentativeWebVrMode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enterVrWithCorrectWindowMode(final boolean tentativeWebVrMode) {
|
||||
if (mInVr) return;
|
||||
if (mNativeVrShellDelegate == 0) {
|
||||
cancelPendingVrEntry();
|
||||
return;
|
||||
}
|
||||
mInVr = true;
|
||||
setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
boolean donSuceeded = mDonSucceeded;
|
||||
mDonSucceeded = false;
|
||||
if (!createVrShell()) {
|
||||
@ -750,10 +722,6 @@ public class VrShellDelegate
|
||||
}
|
||||
mExitedDueToUnsupportedMode = false;
|
||||
|
||||
// Lock orientation to landscape after enter VR.
|
||||
mActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
ScreenOrientationDelegateManager.setOrientationDelegate(this);
|
||||
|
||||
addVrViews();
|
||||
boolean webVrMode = mRequestedWebVr || tentativeWebVrMode && !mAutopresentWebVr;
|
||||
mVrShell.initializeNative(mActivity.getActivityTab(), webVrMode, mAutopresentWebVr,
|
||||
@ -1201,8 +1169,6 @@ public class VrShellDelegate
|
||||
}
|
||||
|
||||
private void cancelPendingVrEntry() {
|
||||
// Ensure we can't asynchronously enter VR after trying to exit it.
|
||||
mEnterVrHandler.removeCallbacksAndMessages(null);
|
||||
removeBlackOverlayView(mActivity);
|
||||
mDonSucceeded = false;
|
||||
if (!mShowingDaydreamDoff) {
|
||||
|
@ -530,7 +530,11 @@ public class VrShellImpl
|
||||
mTab.removeObserver(mTabObserver);
|
||||
restoreTabFromVR();
|
||||
|
||||
if (mTab != null) mTab.updateBrowserControlsState(BrowserControlsState.SHOWN, true);
|
||||
if (mTab != null) {
|
||||
View parent = mTab.getContentViewCore().getContainerView();
|
||||
mTab.getContentViewCore().onSizeChanged(parent.getWidth(), parent.getHeight(), 0, 0);
|
||||
mTab.updateBrowserControlsState(BrowserControlsState.SHOWN, true);
|
||||
}
|
||||
|
||||
mContentVirtualDisplay.destroy();
|
||||
super.shutdown();
|
||||
|
Reference in New Issue
Block a user