perf(android): avoid animation stalls in capture and viewport reads

Merged
TH
12h ago
+338-60

Summary

Follow-up to #3558: Android capture and viewport reads stalled on busy apps.

  • Batch up to eight sibling accessibility reads, preserving order, limits, freshness, and cleanup.
  • Share window preparation between captures and viewport reads. Retain the 100 ms quiet interval; reduce the viewport's maximum idle wait from two seconds to 500 ms. Snapshot settings remain unchanged.
  • Unify node/window bounds serialization. Make the cleanup concurrency test deterministic and document optional keyboard headers.

Nine helper files changed. Scope expanded to viewport reads and serialization at the user's request.

Validation

Head 7a74fb8e354a5606385c8e6d571018e242251f7d, rebased onto c966724beafd8be5106337a4d95018278666237c; range-diff preserves the original commits.

  • pnpm build:android and full-repository pnpm format: passed.
  • pnpm check:affected --run --head HEAD: passed at the named SHA, receipt run-kMrAQk, exactCommit: true. Helper builds are GitHub-authoritative; full replay is manual-dispatch. Both skipped locally.
  • API 35 viewport: continuous events 2018 → 510 ms; keyboard-resized window 2013 → 515 ms, identical responses. Static reads remained fast.
  • Immediate tap-then-scroll verification passed three times; swipes stayed above the appearing keyboard and the app scrolled.
  • JVM suite passed; an isolated early-return mutation was detected by the cleanup test. Independent review passed.

Earlier capture evidence at 2ecc952318: 2.79 → 0.74 s. Bounds writer CPU/allocation improved in isolation; full snapshot timing was unchanged within noise. Original RN screen and API 23–32 devices remain unverified. CI results are separate.