Skip to content

perf(scroll): skip the movement read a stored tree of another presentation cannot be compared with - #5152

Merged
thymikee merged 1 commit into
callstack:mainfrom
imranbarbhuiya:perf/scroll-skip-incomparable-capture
Nov 27, 2026
Merged

thymikee merged 1 commit into
callstack:mainfrom
imranbarbhuiya:perf/scroll-skip-incomparable-capture

Conversation

@imranbarbhuiya

@imranbarbhuiya imranbarbhuiya commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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, head 5782a0f5e8; untraced head on both devices: -i scrolls unobserved, full-tree scrolls moved.
  • 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-related passed.

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

@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 2 files

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

Thanks for the contribution; the code at 5782a0f needs no changes. Checks on this commit pass or are skipped, and a successful Body rules run on the same commit supersedes the two cancelled ones.

Not verified here: no tests or device runs were executed, and the timings and device results are as reported in the PR description, with no linked raw output. Not verified here: why the description gives 48 scrolls per build per platform and also 60/60 unobserved per platform. Not verified here: the effect on a screenshot or raw-coordinate action sent right after such a scroll, which now starts about one capture sooner relative to the gesture.

Merging is the maintainer’s decision.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 27, 2026
@thymikee
thymikee merged commit f0b3cb6 into callstack:main Nov 27, 2026
15 of 17 checks passed
@thymikee

Copy link
Copy Markdown
Member

Nice one, thanks!

@imranbarbhuiya
imranbarbhuiya deleted the perf/scroll-skip-incomparable-capture branch December 2, 2026 07:48
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.

2 participants