Repository navigation
test(android-e2e): wait for the foreground to leave the fixture after Home - #5045
Conversation
… Home (#4990) The Android smoke lane failed at the Home foreground assertion on three unrelated 0.22 PRs (jobs 137197315801, 137220955468, 137350879830). Each run shows the same ordering: `home` finished after 55-121 ms (one injected keyevent), the next `appstate` read started 90-193 ms later, answered in 193-443 ms, and still named com.callstack.agentdevicelab/MainActivity. The retained failed-step evidence for run 45068801264 shows `topResumedActivity=NexusLauncherActivity` about 1.5 s after the keyevent, so Home did happen; the scenario read the foreground while WindowManager was still resuming the launcher. #4716 added the bounded wait for the pixel transition and kept the single unconditional foreground read. `assertHomeAndRecentsRestoration` now waits at that observation with `waitForForegroundLeaves` (same owner, deadline, poll and per-read bound as `waitForSurfaceChange`), and the lane reads pixels only once the device itself reports the foreground left the fixture. A foreground that never leaves fails at the deadline with its last observation; no sleep, no assertion retry, no relaxed check. Coverage runs through the harness entry: a scripted device that keeps the foreground stale for the first reads passes only via the wait (the pre-fix route fails it with the hosted notStrictEqual signature), and a foreground that never transitions fails the lane before any Home-surface capture. The wait owns delayed reads, read failures, reads that answer no package, reads bounded to the remaining deadline, and late observations.
Size Report
Startup median (7 runs, lower is better):
|
Apex Sentinel · ✅ Approve · review of
|
| Command | What it does |
|---|---|
@apex-sentinel-staging note <context> |
Adds context; Sentinel re-checks the cited code |
@apex-sentinel-staging pivot <why> |
Says the finding is wrong; Sentinel re-checks the cited code |
@apex-sentinel-staging like |
Marks the finding as useful |
@apex-sentinel-staging dislike <why> |
Marks it as not useful, so it is not raised again |
On this conversation, comment @apex-sentinel-staging review to run a full review once again.
|
The PR is ready at ae8463a. The new foreground wait in the live-surface transition helper looks correct, and the required evidence is in place. The checks show everything passing except the two cancelled Body rules runs, which only exercise PR body text and not the files this diff changes, so those need a rerun before merge. No conflicts. Not blocking, and fine to take or leave: waitForForegroundLeaves at https://github.com/callstack/agent-device/blob/ae8463a/test/integration/android-emulator-e2e/live-surface-transition.ts#L118 repeats the deadline, poll and last-observation loop of waitForSurfaceChange, so a follow-up could extract one shared poll helper; and the wait at line 135 ends on any non-fixture package, including a system dialog, as the replaced check did, so Home returning to a launcher is not asserted. Not verified here: the tests were not run locally, the Smoke Tests job log was not inspected, and whether runStep with allowFailure rejects or returns on a CLI timeout was not traced. |
… Home (#4990) (#5045) The Android smoke lane failed at the Home foreground assertion on three unrelated 0.22 PRs (jobs 137197315801, 137220955468, 137350879830). Each run shows the same ordering: `home` finished after 55-121 ms (one injected keyevent), the next `appstate` read started 90-193 ms later, answered in 193-443 ms, and still named com.callstack.agentdevicelab/MainActivity. The retained failed-step evidence for run 45068801264 shows `topResumedActivity=NexusLauncherActivity` about 1.5 s after the keyevent, so Home did happen; the scenario read the foreground while WindowManager was still resuming the launcher. #4716 added the bounded wait for the pixel transition and kept the single unconditional foreground read. `assertHomeAndRecentsRestoration` now waits at that observation with `waitForForegroundLeaves` (same owner, deadline, poll and per-read bound as `waitForSurfaceChange`), and the lane reads pixels only once the device itself reports the foreground left the fixture. A foreground that never leaves fails at the deadline with its last observation; no sleep, no assertion retry, no relaxed check. Coverage runs through the harness entry: a scripted device that keeps the foreground stale for the first reads passes only via the wait (the pre-fix route fails it with the hosted notStrictEqual signature), and a foreground that never transitions fails the lane before any Home-surface capture. The wait owns delayed reads, read failures, reads that answer no package, reads bounded to the remaining deadline, and late observations.
Summary
Closes #4990.
assertHomeAndRecentsRestorationread the foreground once afterhome, so the smoke lane failed when that read landed while WindowManager was still resuming the launcher. All three reported runs show one ordering:homefinished after 55-121 ms (one injected keyevent), the nextappstateread started 90-193 ms later, answered in 193-443 ms, and still namedcom.callstack.agentdevicelab/MainActivity. Run 45068801264's failed-step evidence showstopResumedActivity=NexusLauncherActivityabout 1.5 s after the keyevent, so Home did happen; the read was early. #4716 bounded the pixel transition and kept this single read. The lane now waits at that owner withwaitForForegroundLeaves— the same deadline, poll and per-attempt bound aswaitForSurfaceChange— and reads pixels only once the device reports the foreground left the fixture. A foreground that never leaves fails at the deadline with its last observation. Test harness only.Before / after
The scenario through
runScenario, scripted to answer the firstappstatereads after Home with the fixture package:notStrictEqual, actual = expected =com.callstack.agentdevicelab— the hosted signature.read Android Home foreground state (attempt N)steps. A foreground that never transitions rejects at the deadline, before any Home-surface capture.Validation
Head
ae8463ae7conorigin/0.22(80678b6823).pnpm install --frozen-lockfile,pnpm build, typecheck, format, oxlint, and the five android-emulator-e2e suites passed: 39/39, 7 new tests.pnpm check:affected --run --base origin/0.22 --head ae8463ae7cpassedexactCommit=true(receipt.tmp/validation/run-gaUrUm). HostedSmoke Testsruns the live Android lane; no local device was allocated here.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.