Skip to content

test(android): bound the screenshot write wait by wall time, not event-loop turns - #3250

Merged
thymikee merged 1 commit into
mainfrom
fix/android-screenshot-rotation-probe-flake
Oct 6, 2026
Merged

thymikee merged 1 commit into
mainfrom
fix/android-screenshot-rotation-probe-flake

Conversation

@thymikee

@thymikee thymikee commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

screenshotAndroid drops a display rotation probe still running after the capture flaked on Coverage CI (run, on #3241, which doesn't touch this code). It failed with "the capture must start one grace timer once written".

The test waits for the real PNG write, which runs on the libuv thread pool, before asserting that the 250 ms grace timer is installed. It allowed a fixed 1,000 setImmediate turns, but a loaded thread pool can need more than that. The wait is now bounded by wall time (10 s, performance.now(), which the fake timers don't touch, since only setTimeout/clearTimeout are faked). The assertions are unchanged.

Validation

  • Reproduced locally by holding the thread pool for about 300 ms (UV_THREADPOOL_SIZE=1 plus one pbkdf2 call) during the capture. The old test fails with the CI assertion; the new one passes.
  • pnpm check:affected --run passed.

🤖 Generated with Claude Code

Review in cubic

…t-loop turns

The rotation-probe test yielded 1,000 setImmediate turns for the PNG write to
finish; a loaded libuv thread pool (Coverage CI) can need more, so the grace
timer was not yet installed and the test failed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.08 MB 5.08 MB 0 B
Package (unpacked) 5.08 MB 5.08 MB 0 B
Package (download) 1.53 MB 1.53 MB +3 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.8 ms 28.7 ms +1.0 ms
CLI --help 85.9 ms 85.6 ms -0.2 ms

@thymikee

thymikee commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

PR #3250 is ready at 027701b, and I found nothing that needs a change. CI is green, and I know of no conflicts. I did not run the test locally, and I did not check the installed Vitest version's fake-timer behavior beyond the package.json range.

Not blocking: the write deadline at https://github.com/callstack/agent-device/blob/027701b/packages/platform-android/src/__tests__/screenshot.test.ts#L104 is 10 s, but the config sets no testTimeout, so Vitest's 5 s default applies. A stalled write would then fail with a generic timeout instead of the "capture must start one grace timer once written" assertion, and the loop would keep running with fake timers until the 10 s mark. You could set the deadline below 5 s (for example 4_000) or give the test an explicit timeout above 10 s. Take it or leave it.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 6, 2026
@thymikee
thymikee merged commit f5b48d8 into main Oct 6, 2026
18 checks passed
@thymikee
thymikee deleted the fix/android-screenshot-rotation-probe-flake branch October 6, 2026 06:55
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-06 06:55 UTC

thymikee added a commit to okwasniewski/agent-device that referenced this pull request Oct 6, 2026
* origin/main: (77 commits)
  fix(apple-runner): fence prep spawns behind a start-owned admission (callstack#3239)
  0.21.22
  test(apple): own the simctl settings plan tests in simctl-settings.test.ts (callstack#3244)
  fix(limrun): report the session device id in iOS settings refusals (callstack#3243)
  0.21.21
  feat(remote): add a host-allocated macos-app lease backend (callstack#3236)
  test(android): bound the screenshot write wait by wall time, not event-loop turns (callstack#3250)
  feat(recording): cap the touch overlay frame rate at the caller's --fps (callstack#3241)
  fix(ad-script): let .ad scripts carry scroll --until and wait capture flags (callstack#3197) (callstack#3234)
  feat(provider-webdriver): keyboard enter, dismiss, and status over WebDriver (callstack#3233)
  feat(selectors): match role= against snapshot kind with a node-scoped alias window (callstack#3232)
  fix(provider-webdriver): read field values, placeholders, secure fields, and checked state from page source (callstack#3231)
  feat(replay): accept --test-ime on test and replay so flow-owned Android opens opt into the test IME (callstack#3235)
  refactor(daemon): route daemon-level diagnostics through one scope helper (callstack#3242)
  docs(adr): correct ADR 0031 pointer event delivery evidence (callstack#3245)
  fix(ios): stop a tap's post-gesture lookup from recording an XCTest failure (callstack#3060) (callstack#3237)
  fix(recording): render the touch overlay at most 30 fps and inside the record request (callstack#3219)
  fix(daemon): keep an idle daemon alive only for retained leases (callstack#3227)
  fix(provider-webdriver): send an empty JSON object on bodyless POSTs (callstack#3230)
  Feat/maestro repeat while (callstack#3214)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant