perf(scroll): skip the movement read a stored tree of another presentation cannot be compared with
Summary
A directional scroll reads the default full tree afterwards to decide whether it may claim movement (#2776). surfacePairDrift never compares that read with a stored tree of another presentation, such as the interactive-only tree snapshot -i keeps. So after snapshot -i, the common agent step, every scroll paid for a capture that could only answer unobserved (baseline-presentation-drift).
planScrollMovement now compares presentation keys before the gesture and returns that same answer without the capture. It runs after the staleness checks, so their reasons still come first; a stored default tree is read and compared as before.
Before / after (iOS 27.2 simulator and Android 16 Pixel 9 emulator, Settings)
Builds taking turns on one device, 48 scrolls per build per platform, daemon-side medians:
| Flow | Base | Head | Delta [95% CI] |
|---|---|---|---|
iOS scroll after snapshot -i | 924 ms | 710 ms | −214 ms [−241, −177] |
Android scroll after snapshot -i | 641 ms | 408 ms | −234 ms [−271, −205] |
iOS scroll after snapshot (control) | 954 ms | 906 ms | within noise |
Android scroll after snapshot (control) | 606 ms | 596 ms | within noise |
Captures per scroll: 1 → 0 after snapshot -i, unchanged after snapshot. Both builds returned unobserved for every -i scroll (60/60 per platform) and moved for the controls.
Validation
- Base
b69cf45666, head5782a0f5e8; untraced head on both devices:-iscrollsunobserved, full-tree scrollsmoved. scroll-movement.test.ts: 39 passed; removing the check or moving it before the staleness checks fails a test.- Gate:
format,lint,typecheck,layering,fallow,build,vitest-relatedpassed.
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.