Skip to content

Commit

Permalink
[M100] Increase XR test timeouts
Browse files Browse the repository at this point in the history
Increases the timeouts used for XR end-to-end tests. On the JavaScript
side, the entire test timeout is bumped up from 10 to 30 seconds. On the
Java side, individual step timeouts are doubled when running on older/
slower devices (currently just marlin).

This seems to make a significant improvement in the random failures we
were getting on N/O.

(cherry picked from commit 111d120)

Bug: 1300966
Change-Id: I092e267f819079eb64d9344dd5aad74aefbe430f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3531071
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#981939}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3541024
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/4896@{#765}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
Brian Sheedy authored and Chromium LUCI CQ committed Mar 21, 2022
1 parent 140afbd commit 226dff5
Show file tree
Hide file tree
Showing 38 changed files with 32 additions and 74 deletions.
Expand Up @@ -4,6 +4,7 @@

package org.chromium.chrome.browser.vr;

import android.os.Build;
import android.view.View;

import androidx.annotation.IntDef;
Expand All @@ -27,6 +28,8 @@

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.HashSet;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand Down Expand Up @@ -55,11 +58,12 @@
* which can then grab the results and pass/fail the instrumentation test.
*/
public abstract class XrTestFramework {
public static final HashSet<String> OLD_DEVICE_BOARDS = new HashSet(Arrays.asList("marlin"));
public static final int PAGE_LOAD_TIMEOUT_S = 10;
public static final int POLL_CHECK_INTERVAL_SHORT_MS = 50;
public static final int POLL_CHECK_INTERVAL_LONG_MS = 100;
public static final int POLL_TIMEOUT_SHORT_MS = 1000;
public static final int POLL_TIMEOUT_LONG_MS = 10000;
public static final int POLL_TIMEOUT_SHORT_MS = getShortPollTimeout();
public static final int POLL_TIMEOUT_LONG_MS = getLongPollTimeout();
public static final boolean DEBUG_LOGS = false;

// We need to make sure the port is constant, otherwise the URL changes between test runs, which
Expand Down Expand Up @@ -89,6 +93,22 @@ public abstract class XrTestFramework {

private ChromeActivityTestRule mRule;

static final int getShortPollTimeout() {
return getPollTimeout(1000);
}

static final int getLongPollTimeout() {
return getPollTimeout(10000);
}

static final int getPollTimeout(int baseTimeout) {
// Increase the timeouts on older devices, as the tests can be rather slow on them.
if (OLD_DEVICE_BOARDS.contains(Build.BOARD)) {
baseTimeout *= 2;
}
return baseTimeout;
}

/**
* Gets the file:// URL to the test file.
*
Expand Down
Expand Up @@ -11,8 +11,6 @@
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script>
<script>
setup({single_test: true});

let session = null;
let testFrames = 5;
let numFramesReceived = 0;
Expand Down
Expand Up @@ -20,8 +20,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

// Override the reference space map to only request eye-level stationary
// reference spaces, as opposed to the identity MagicWindow/AR spaces.
referenceSpaceMap = {
Expand Down
Expand Up @@ -10,8 +10,6 @@
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script>
<script>
setup({single_test: true});

let session_ = null;
navigator.xr.requestSession('inline')
.then((xrSession) => {
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

let counter = 0;

function stepBeforeImmersive() {
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

// Set the optional features to request secondary views when requesting
// a session. This global is defined and used in webxr_boilerplate.js.
immersiveSessionInit = {
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var expectations = {
"Daydream": {
"immersive": true,
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script src="../resources/webxr_e2e.js"></script>
</body>
<script>
setup({single_test: true});

if (navigator.xr) {
assert_unreached("API is visible");
}
Expand Down
Expand Up @@ -11,8 +11,6 @@
<script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
<script src="../resources/webxr_e2e.js"></script>
<script>
setup({single_test: true});

navigator.xr.isSessionSupported('immersive-vr').then((supported) => {
assert_false(supported, "WebXR indicated support for 'immersive-vr'");
done();
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

// We apparently need to register a listener, otherwise all gamepads are
// always null.
window.addEventListener("gamepadconnected", function(e) {});
Expand Down
2 changes: 0 additions & 2 deletions chrome/test/data/xr/e2e_test_files/html/test_webxr_input.html
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var selectStartCount = 0;
var selectEndCount = 0;
var selectCount = 0;
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

let inputChangeEvents = 0;
function onInputSourcesChange() {
inputChangeEvents++;
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

let inputChangeEvents = 0;
let lastAdded = null;
let lastRemoved = null;
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

function finishTest() {
done();
}
Expand Down
2 changes: 0 additions & 2 deletions chrome/test/data/xr/e2e_test_files/html/test_webxr_poses.html
Expand Up @@ -15,8 +15,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var frame_id = 0;
var frame_data_array = {};
var pose_array = {};
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

onSessionEnded = function(event) {
sessionInfos[getSessionType(event.session)].clearSession();
if (hasPresentedFrame) {
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var selectStartCount = 0;
var selectEndCount = 0;
var selectCount = 0;
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

onMagicWindowXRFrameCallback = function() {
window.requestAnimationFrame( () => {
done();
Expand Down
Expand Up @@ -24,8 +24,6 @@
dataFormatPreference: ['luminance-alpha'],
};

setup({single_test: true});

function disableCameraAccess() {
const indexToRemove = immersiveArSessionInit.requiredFeatures.indexOf("camera-access");
if(indexToRemove != -1) {
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

const TestState = Object.freeze({
"Initial": 0,
"SpaceObtained": 1,
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

const TestState = Object.freeze({
"Initial": 0,
"HitTestSourceAvailable": 1, // hitTestSource variable is guaranteed to be non-null in this state
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

const TestState = Object.freeze({
"Initial": 0,
"HitTestSourceAvailable": 1, // hitTestSource variable is guaranteed to be non-null in this state
Expand Down
Expand Up @@ -18,8 +18,6 @@
dataFormatPreference: ['luminance-alpha'],
};

setup({single_test: true});

function stepStartDepthTest() {
const sessionInfo = sessionInfos[sessionTypes.AR];
const session = sessionInfo.currentSession;
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

let gotResult = false;
let hitTestSource = null;

Expand Down
Expand Up @@ -12,8 +12,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

const TestState = Object.freeze({
"Initial": 0,
"HitTestSourceRequested": 1,
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

const TestState = Object.freeze({
"Initial": 0,
"RequestHitTestSource": 1,
Expand Down
Expand Up @@ -14,8 +14,6 @@
<script>
immersiveArSessionInit.requiredFeatures.push('light-estimation');

setup({single_test: true});

function stepStartLightEstimationTest() {
const FLOAT_EPSILON = 0.001;
const isCloseToZero = (coefficient) => Math.abs(coefficient) < FLOAT_EPSILON;
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script>var shouldAutoCreateNonImmersiveSession = false;</script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

// Tests that requesting a viewport scale takes effect immediately if done
// before calling getViewport.
function stepRequestViewportScaleSameFrame() {
Expand Down
Expand Up @@ -14,8 +14,6 @@
<!-- Required features must be set after importing webxr_boilerplate.js to avoid overwrite -->
<script>var immersiveArSessionInit = { requiredFeatures: ['camera-access'] };</script>
<script>
setup({single_test: true});

// How many frames with viewer poses some tests will wait for until trying to
// exercise the API and run the test case:
const MIN_NUM_FRAMES_WITH_POSES = 10;
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var pose = null;
let counter = 0;

Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var rafCount = 0;

function stepSetupFocusLoss() {
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

function onImmersiveRequestWithDon() {
navigator.xr.requestSession('immersive-vr').then( (session) => {
assert_unreached("requestPresent promise resolved");
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

function onImmersiveRequestWithDon() {
navigator.xr.requestSession('immersive-vr').then( (session) => {
assert_unreached("requestSession promise resolved");
Expand Down
Expand Up @@ -12,8 +12,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

var numTaps = 0;
webglCanvas.addEventListener("click", () => {numTaps++;}, false);

Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

function currentImmersiveSession() {
return sessionInfos[sessionTypes.IMMERSIVE].currentSession;
}
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

function stepVerifyBeforePresent() {
window.requestAnimationFrame( () => {
finishJavaScriptStep();
Expand Down
Expand Up @@ -13,8 +13,6 @@
<script src="../resources/webxr_e2e.js"></script>
<script src="../resources/webxr_boilerplate.js"></script>
<script>
setup({single_test: true});

function stepVerifyBeforePresent() {
window.requestAnimationFrame( () => {
finishJavaScriptStep();
Expand Down
10 changes: 10 additions & 0 deletions chrome/test/data/xr/e2e_test_files/resources/webxr_e2e.js
Expand Up @@ -93,3 +93,13 @@ if (typeof add_completion_callback !== "undefined") {
finishJavaScriptStep();
});
}

if (typeof setup !== "undefined") {
// The timeout multiplier helps with erroneous timeouts on slower Android
// devices. 3 was chosen because it's a midpoint between the standard 10 and
// long 60 second timeouts that are used for web tests using testharness.js
// and it's a bit more of a multiplier than the 2x increase in step timeouts
// we have for slow devices, which is reasonable since this is the timeout for
// the entire test rather than a single step.
setup({single_test: true, timeout_multiplier: 3});
}

0 comments on commit 226dff5

Please sign in to comment.