From a9564b01a250feb967e052314c151276dd4b754b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Thu, 22 Oct 2026 17:46:06 +0200 Subject: [PATCH] perf: expect the persistent session on Android snapshot-raw Fail the heavy-feed snapshot-raw step with expectation_failed when the persistent helper session did not answer, so one-shot timings stay out of the session baseline. Drop the redundant second sessionCapture assignment in the helper capture flow. Follow-up to #3902. Co-Authored-By: Claude Sonnet 5.5 --- packages/platform-android/src/snapshot.ts | 2 +- scripts/perf/README.md | 2 +- scripts/perf/suite.test.ts | 17 +++++++++++++++++ scripts/perf/suite.ts | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/platform-android/src/snapshot.ts b/packages/platform-android/src/snapshot.ts index 31f9e3d75e..923c23c14a 100644 --- a/packages/platform-android/src/snapshot.ts +++ b/packages/platform-android/src/snapshot.ts @@ -479,7 +479,7 @@ async function captureAndroidUiHierarchyFromHelper(params: { captureOptions.idleWait = params.idleWait; let sessionCapture: AndroidSnapshotHelperOutput | undefined; try { - sessionCapture = await withDiagnosticTimer( + await withDiagnosticTimer( ANDROID_SNAPSHOT_HELPER_SESSION_CAPTURE_PHASE, async () => (sessionCapture = await captureAndroidSnapshotWithHelperSession(captureOptions)), () => ({ diff --git a/scripts/perf/README.md b/scripts/perf/README.md index 5ea3867642..119e648f3c 100644 --- a/scripts/perf/README.md +++ b/scripts/perf/README.md @@ -44,7 +44,7 @@ At the end, or on SIGINT or SIGTERM, the suite saves the logs to `raw/state/`, s Each platform times the normal snapshot path and one forced path. - iOS: the simulator accessibility bridge answers normal captures. `home-reads/snapshot-forced-tree` pins the XCTest tree backend through the SDK, because the CLI has no flag for it. Only a regular capture honors the pin; a raw capture runs its own backend ladder. The response must name the `tree` backend with the `requested-backend` reason code. The XCTest tree rejects the heavy feed, so the step runs on the home screen. -- Android: the snapshot helper APK is the only snapshot engine (ADR 0002). Its persistent session answers normal captures. `snapshot-raw-one-shot` restarts the daemon with `AGENT_DEVICE_ANDROID_SNAPSHOT_HELPER_SESSION=0`, so a one-shot `am instrument` capture answers. The harness restarts the daemon without the variable after the step. Both raw captures must reach depth 56. The forced capture must report the `instrumentation` transport. +- Android: the snapshot helper APK is the only snapshot engine (ADR 0002). Its persistent session answers normal captures. `snapshot-raw-one-shot` restarts the daemon with `AGENT_DEVICE_ANDROID_SNAPSHOT_HELPER_SESSION=0`, so a one-shot `am instrument` capture answers. The harness restarts the daemon without the variable after the step. Both raw captures must reach depth 56. `snapshot-raw` must report the `persistent-session` transport, and the forced capture must report the `instrumentation` transport. ## Platform parity diff --git a/scripts/perf/suite.test.ts b/scripts/perf/suite.test.ts index 22ec9c85d4..77f505c512 100644 --- a/scripts/perf/suite.test.ts +++ b/scripts/perf/suite.test.ts @@ -100,3 +100,20 @@ test('an Android capture breaks its expectation when another helper transport se ); assert.match(expectationViolation(oneShot, {})!, /unknown transport/); }); + +test('the Android heavy-feed raw capture expects the persistent session to answer', () => { + const heavyFeed = suiteFor('android').find((s) => s.id === 'heavy-feed')!; + const raw = heavyFeed.steps.find((s) => s.id === 'snapshot-raw')!; + assert.match( + expectationViolation(raw.expect, { maxDepth: 60, transport: 'instrumentation' })!, + /instrumentation transport served the capture, not persistent-session/, + ); + assert.equal( + expectationViolation(raw.expect, { maxDepth: 60, transport: 'persistent-session' }), + undefined, + ); + const iosRaw = suiteFor('ios') + .find((s) => s.id === 'heavy-feed')! + .steps.find((s) => s.id === 'snapshot-raw')!; + assert.equal(iosRaw.expect?.transport, undefined); +}); diff --git a/scripts/perf/suite.ts b/scripts/perf/suite.ts index 27f09f47a5..d487b8132b 100644 --- a/scripts/perf/suite.ts +++ b/scripts/perf/suite.ts @@ -373,7 +373,7 @@ export const SUITE: readonly SuiteScenario[] = [ // The fixture renders more than 65 native levels on iOS and 60 on Android. step('snapshot-raw', C.snapshot, ['snapshot', '--raw'], { expect: { maxDepthAtLeast: 64 }, - on: { android: { expect: { maxDepthAtLeast: 56 } } }, + on: { android: { expect: { maxDepthAtLeast: 56, transport: 'persistent-session' } } }, }), step('press-like-selector', C.press, ['press', 'id="heavy-post-0-like"']), step('press-like-settle', C.press, ['press', 'id="heavy-post-1-like"', '--settle']),