Commit 45aacc7e authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Revert "VR: Cancel stay_hidden animation when VR UI is ready to be shown."

This reverts commit 50a17030.

Reason for revert: https://bugs.chromium.org/p/chromium/issues/detail?id=741761

Original change's description:
> VR: Cancel stay_hidden animation when VR UI is ready to be shown.
> 
> This replaces hugely hacky behaviour where we assumed Chrome would start
> up within 500ms because we couldn't figure out how to cancel the
> activity animation, with only moderately hacky behaviour where we start
> a noDisplay activity in order to cancel the animation.
> 
> The duration of the stay_hidden animation has been increased to the max
> duration of 10s, giving chrome ample time to start up while hidden and
> then cancel the animation.
> 
> Bug: 740004
> Change-Id: I0f2c8daac7b0f692f0ed5a9bbfefe29a925811e6
> Reviewed-on: https://chromium-review.googlesource.com/567336
> Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
> Reviewed-by: Yash Malik <ymalik@chromium.org>
> Reviewed-by: David Trainor <dtrainor@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#485980}

TBR=mthiesse@chromium.org,dtrainor@chromium.org,ymalik@chromium.org

Change-Id: Iee18c28ac9a047e0e281ed6fe5defd0cde1eec9a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 740004
Reviewed-on: https://chromium-review.googlesource.com/568638Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486015}
parent 7e3d0c03
...@@ -619,16 +619,6 @@ by a child template that "extends" this file. ...@@ -619,16 +619,6 @@ by a child template that "extends" this file.
android:excludeFromRecents="true"> android:excludeFromRecents="true">
</activity> </activity>
<activity
android:name="org.chromium.chrome.browser.vr_shell.VrCancelAnimationActivity"
android:exported="false"
android:theme="@android:style/Theme.NoDisplay"
android:noHistory="true"
android:excludeFromRecents="true"
android:enableVrMode="@string/gvr_vr_mode_component">
{{ self.supports_vr() }}
</activity>
<!-- Service for handling Nearby Messages --> <!-- Service for handling Nearby Messages -->
<service android:name="org.chromium.chrome.browser.physicalweb.NearbyMessageIntentService" <service android:name="org.chromium.chrome.browser.physicalweb.NearbyMessageIntentService"
android:exported="false" /> android:exported="false" />
......
...@@ -6,8 +6,10 @@ ...@@ -6,8 +6,10 @@
<!-- The delay here must be long enough for the Activity being resumed to draw <!-- The delay here must be long enough for the Activity being resumed to draw
its first frame of UI. This is to avoid showing stale 2D screenshots when its first frame of UI. This is to avoid showing stale 2D screenshots when
launching Chrome in VR. We cancel this animation upon entering VR. --> launching Chrome in VR. Note that the larger this value is, the more
latency we add to resuming Chrome after going through the Daydream Device
ON flow. -->
<alpha xmlns:android="http://schemas.android.com/apk/res/android" <alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator" android:interpolator="@android:anim/linear_interpolator"
android:fromAlpha="0" android:toAlpha="0" android:fromAlpha="0" android:toAlpha="0"
android:duration="10000" /> android:duration="500" />
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.vr_shell;
import android.app.Activity;
import android.os.Bundle;
/**
* Cancel the startActivity animation used to keep 2D UI hidden while Chrome is starting up.
* See the comments in VrShellDelegate.VrBroadcastReceiver#onReceive for more information.
*/
public class VrCancelAnimationActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
finish();
overridePendingTransition(0, 0);
}
}
\ No newline at end of file
...@@ -136,8 +136,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -136,8 +136,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
private final Handler mEnterVrHandler; private final Handler mEnterVrHandler;
private final Handler mExpectPauseOrDonSucceeded; private final Handler mExpectPauseOrDonSucceeded;
private boolean mProbablyInDon; private boolean mProbablyInDon;
private boolean mNeedsAnimationCancel;
private boolean mCancellingEntryAnimation;
// Whether or not the VR Device ON flow succeeded. If this is true it means the user has a VR // Whether or not the VR Device ON flow succeeded. If this is true it means the user has a VR
// headset on, but we haven't switched into VR mode yet. // headset on, but we haven't switched into VR mode yet.
...@@ -198,12 +196,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -198,12 +196,13 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
// However, if we're already in VR (in one of the cases where we chose not to exit // However, if we're already in VR (in one of the cases where we chose not to exit
// VR before the DON flow), we don't need to add the overlay. // VR before the DON flow), we don't need to add the overlay.
if (!sInstance.mInVr) sInstance.addOverlayView(); if (!sInstance.mInVr) sInstance.addOverlayView();
sInstance.mNeedsAnimationCancel = !sInstance.mInVr;
// We start the Activity with a custom animation that keeps it hidden while starting // We start the Activity with a custom animation that keeps it hidden for a few
// up to avoid Android showing stale 2D screenshots when the user is in their VR // hundred milliseconds - enough time for us to draw the first black view.
// headset. The animation lasts up to 10 seconds, but is cancelled when we're // TODO(mthiesse): This is really hacky. If we can find a way to cancel the
// resumed as at that time we'll be showing the black overlay added above. // transition animation (I couldn't), then we can just make it indefinite until the
// VR UI is ready, and then cancel it, rather than trying to guess how long it will
// take to draw the first view, and possibly adding latency to VR startup.
int animation = sInstance.mInVr ? 0 : R.anim.stay_hidden; int animation = sInstance.mInVr ? 0 : R.anim.stay_hidden;
Bundle options = Bundle options =
ActivityOptions.makeCustomAnimation(activity, animation, 0).toBundle(); ActivityOptions.makeCustomAnimation(activity, animation, 0).toBundle();
...@@ -592,9 +591,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -592,9 +591,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
case ActivityState.STOPPED: case ActivityState.STOPPED:
if (activity == mActivity) onStop(); if (activity == mActivity) onStop();
break; break;
case ActivityState.STARTED:
if (activity == mActivity) onStart();
break;
case ActivityState.RESUMED: case ActivityState.RESUMED:
if (mInVr && activity != mActivity) { if (mInVr && activity != mActivity) {
if (mShowingDaydreamDoff) { if (mShowingDaydreamDoff) {
...@@ -714,7 +710,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -714,7 +710,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
cancelPendingVrEntry(); cancelPendingVrEntry();
return; return;
} }
mVrClassesWrapper.setVrModeEnabled(mActivity, true);
if (!isWindowModeCorrectForVr()) { if (!isWindowModeCorrectForVr()) {
setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
mEnterVrHandler.post(new Runnable() { mEnterVrHandler.post(new Runnable() {
...@@ -747,11 +742,12 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -747,11 +742,12 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mDonSucceeded = false; mDonSucceeded = false;
if (!createVrShell()) { if (!createVrShell()) {
maybeSetPresentResult(false, donSuceeded); maybeSetPresentResult(false, donSuceeded);
mVrDaydreamApi.launchVrHomescreen();
cancelPendingVrEntry(); cancelPendingVrEntry();
mInVr = false; mInVr = false;
mVrDaydreamApi.launchVrHomescreen();
return; return;
} }
mVrClassesWrapper.setVrModeEnabled(mActivity, true);
mShouldShowPageInfo = false; mShouldShowPageInfo = false;
shutdownNonPresentingNativeContext(); shutdownNonPresentingNativeContext();
...@@ -777,7 +773,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -777,7 +773,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
maybeSetPresentResult(true, donSuceeded); maybeSetPresentResult(true, donSuceeded);
mVrShell.getContainer().setOnSystemUiVisibilityChangeListener(this); mVrShell.getContainer().setOnSystemUiVisibilityChangeListener(this);
removeOverlayView(); removeOverlayView();
if (!donSuceeded && !mAutopresentWebVr && isDaydreamCurrentViewer()) { if (!donSuceeded && !mAutopresentWebVr && isDaydreamCurrentViewer()) {
// TODO(mthiesse): This is a VERY dirty hack. We need to know whether or not entering VR // TODO(mthiesse): This is a VERY dirty hack. We need to know whether or not entering VR
// will trigger the DON flow, so that we can wait for it to complete before we let the // will trigger the DON flow, so that we can wait for it to complete before we let the
...@@ -897,9 +892,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -897,9 +892,7 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
*/ */
@EnterVRResult @EnterVRResult
private int enterVrInternal() { private int enterVrInternal() {
if (mPaused) return ENTER_VR_CANCELLED;
if (mInVr) return ENTER_VR_NOT_NECESSARY; if (mInVr) return ENTER_VR_NOT_NECESSARY;
// Update VR support level as it can change at runtime // Update VR support level as it can change at runtime
updateVrSupportLevel(); updateVrSupportLevel();
if (mVrSupportLevel == VR_NOT_AVAILABLE) return ENTER_VR_CANCELLED; if (mVrSupportLevel == VR_NOT_AVAILABLE) return ENTER_VR_CANCELLED;
...@@ -925,14 +918,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -925,14 +918,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
} }
private void onResume() { private void onResume() {
if (mNeedsAnimationCancel) {
mCancellingEntryAnimation = true;
Bundle options = ActivityOptions.makeCustomAnimation(mActivity, 0, 0).toBundle();
mActivity.startActivity(
new Intent(mActivity, VrCancelAnimationActivity.class), options);
mNeedsAnimationCancel = false;
return;
}
mPaused = false; mPaused = false;
updateVrSupportLevel(); updateVrSupportLevel();
...@@ -971,7 +956,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -971,7 +956,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
} }
if (mDonSucceeded) { if (mDonSucceeded) {
mCancellingEntryAnimation = false;
handleDonFlowSuccess(); handleDonFlowSuccess();
} else if (mRestoreOrientation != null) { } else if (mRestoreOrientation != null) {
// This means the user backed out of the DON flow, and we won't be entering VR. // This means the user backed out of the DON flow, and we won't be entering VR.
...@@ -996,9 +980,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -996,9 +980,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
} }
private void onPause() { private void onPause() {
mPaused = true;
if (mCancellingEntryAnimation) return;
mExpectPauseOrDonSucceeded.removeCallbacksAndMessages(null); mExpectPauseOrDonSucceeded.removeCallbacksAndMessages(null);
mPaused = true;
unregisterDaydreamIntent(mVrDaydreamApi); unregisterDaydreamIntent(mVrDaydreamApi);
if (mVrSupportLevel == VR_NOT_AVAILABLE) return; if (mVrSupportLevel == VR_NOT_AVAILABLE) return;
...@@ -1020,18 +1003,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -1020,18 +1003,8 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mIsDaydreamCurrentViewer = null; mIsDaydreamCurrentViewer = null;
} }
private void onStart() {
if (mDonSucceeded) {
// We're about to enter VR, so set the VR Mode as early as possible to avoid screen
// brightness flickering while in the headset.
mVrClassesWrapper.setVrModeEnabled(mActivity, true);
setWindowModeForVr(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
}
private void onStop() { private void onStop() {
cancelPendingVrEntry(); cancelPendingVrEntry();
assert !mCancellingEntryAnimation;
// We defer pausing of VrShell until the app is stopped to keep head tracking working for // We defer pausing of VrShell until the app is stopped to keep head tracking working for
// as long as possible while going to daydream home. // as long as possible while going to daydream home.
if (mInVr) mVrShell.pause(); if (mInVr) mVrShell.pause();
...@@ -1140,8 +1113,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener, ...@@ -1140,8 +1113,6 @@ public class VrShellDelegate implements ApplicationStatus.ActivityStateListener,
mEnterVrHandler.removeCallbacksAndMessages(null); mEnterVrHandler.removeCallbacksAndMessages(null);
mDonSucceeded = false; mDonSucceeded = false;
removeOverlayView(); removeOverlayView();
mVrClassesWrapper.setVrModeEnabled(mActivity, false);
restoreWindowMode();
} }
/** /**
......
...@@ -1159,7 +1159,6 @@ chrome_java_sources = [ ...@@ -1159,7 +1159,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/util/PlatformUtil.java", "java/src/org/chromium/chrome/browser/util/PlatformUtil.java",
"java/src/org/chromium/chrome/browser/util/UrlUtilities.java", "java/src/org/chromium/chrome/browser/util/UrlUtilities.java",
"java/src/org/chromium/chrome/browser/util/ViewUtils.java", "java/src/org/chromium/chrome/browser/util/ViewUtils.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrCancelAnimationActivity.java",
"java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java", "java/src/org/chromium/chrome/browser/vr_shell/NonPresentingGvrContext.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrClassesWrapper.java", "java/src/org/chromium/chrome/browser/vr_shell/VrClassesWrapper.java",
"java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionChecker.java", "java/src/org/chromium/chrome/browser/vr_shell/VrCoreVersionChecker.java",
......
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