Skip to content

Commit e96de31

Browse files
authored
fix: stabilize android perf harness setup (#657)
1 parent b1aaa3a commit e96de31

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

scripts/perf/harness.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ function buildMeasurement(
126126
};
127127
}
128128

129+
function setupMeasurementFailed(measurement: Measurement): boolean {
130+
return measurement.samples.some((sample) => !sample.ok);
131+
}
132+
129133
// Boot the device once and time it. Runs WITHOUT --session so no session lock policy
130134
// applies and the device selectors are honored (selectors are rejected on locked sessions).
131135
function bootOnce(ctx: IsolationContext): Measurement {
@@ -163,6 +167,10 @@ export function runScenario(ctx: IsolationContext, cfg: PerfConfig): Measurement
163167

164168
const boot = bootOnce(ctx);
165169
const establish = establishSession(ctx);
170+
if (setupMeasurementFailed(boot) || setupMeasurementFailed(establish)) {
171+
log('setup failed; skipping timed tour');
172+
return [boot, establish];
173+
}
166174
// Absorb the one-time runner startup before any round so it isn't charged to a measurement.
167175
warmRunner(ctx);
168176

scripts/perf/platform-profiles.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import type { PerfConfig } from './config.ts';
22
import type { Platform } from './types.ts';
33

44
// Local-convenience defaults for ad-hoc runs; CI always overrides them (--device / --serial).
5-
// The iOS UDID is a specific local "iPhone 17" sim; the Android serial is a dedicated emulator
6-
// port. Pass --udid/--device/--serial to target your own device.
5+
// The iOS UDID is a specific local "iPhone 17" sim; the Android default is an AVD name that
6+
// `boot` can launch. Pass --udid/--device/--serial to target your own device.
77
const DEFAULT_IOS_UDID = 'D74E0B66-57EB-4EC1-92DC-DA0A30581FE7';
8-
const DEFAULT_ANDROID_SERIAL = 'emulator-5556';
8+
const DEFAULT_ANDROID_AVD = 'Pixel_9_Pro_XL_API_37';
99

1010
export type ProfileSelectors = {
1111
// A row on the Settings root that pushes a large sub-screen (big a11y tree).
@@ -57,13 +57,16 @@ export function resolveProfile(cfg: PerfConfig): ResolvedProfile {
5757
},
5858
};
5959
}
60-
const serial = cfg.serial ?? DEFAULT_ANDROID_SERIAL;
60+
const avdName = cfg.device ?? DEFAULT_ANDROID_AVD;
61+
const serialFlags = cfg.serial
62+
? ['--serial', cfg.serial, '--android-device-allowlist', cfg.serial]
63+
: [];
6164
return {
6265
platform: 'android',
63-
deviceName: cfg.serial ? `android (${serial})` : 'Pixel_9_Pro_XL_API_37',
64-
serial,
66+
deviceName: cfg.serial ? `android (${cfg.serial})` : avdName,
67+
serial: cfg.serial,
6568
platformFlags: ['--platform', 'android'],
66-
selectorFlags: ['--serial', serial, '--android-device-allowlist', serial],
69+
selectorFlags: ['--device', avdName, ...serialFlags],
6770
appTarget: 'com.android.settings',
6871
selectors: {
6972
deepScreen: 'text="Network & internet"',

0 commit comments

Comments
 (0)