Repository navigation
perf(SnapPaging): a settle samples its curve once, not once per item - #10568
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| DateInput | 183.2 kB (+533 B) · 16.7 kB CSS (0) | — |
| BottomSheet | 66.1 kB (+525 B) · 7.5 kB CSS (0) | — |
| TimeInput | 158.9 kB (+519 B) · 15.7 kB CSS (0) | — |
32 more components
| Component | Size | LoC |
|---|---|---|
| DateTimeInput | 205.0 kB (+516 B) · 18.4 kB CSS (0) | — |
| PowerSearch | 282.9 kB (+510 B) · 23.6 kB CSS (0) | — |
| Lightbox | 118.3 kB (+505 B) · 10.4 kB CSS (0) | — |
| lab/Comments | 337.6 kB (+493 B) · 2.5 kB CSS (0) | — |
| Switch | 101.1 kB (+490 B) · 9.9 kB CSS (0) | — |
| lab/NavigationScreen | 80.5 kB (+489 B) · 1.5 kB CSS (0) | — |
| lab/TabBar | 75.2 kB (+489 B) · 1.8 kB CSS (0) | — |
| lab/NavigationStack | 80.5 kB (+488 B) · 1.5 kB CSS (0) | — |
| lab/CommentThread | 330.6 kB (+478 B) · 2.4 kB CSS (0) | — |
| SideNav | 111.3 kB (+476 B) · 11.3 kB CSS (0) | — |
| lab/CommentComposer | 147.6 kB (+466 B) · 1.9 kB CSS (0) | — |
| SegmentedControl | 93.0 kB (+463 B) · 6.8 kB CSS (0) | — |
| Popover | 88.3 kB (+462 B) · 13.9 kB CSS (0) | — |
| ChatLayout | 79.7 kB (+459 B) · 10.4 kB CSS (0) | — |
| lab/ChatEmojiPicker | 102.8 kB (+446 B) · 773 B CSS (0) | — |
| Slider | 106.5 kB (+443 B) · 8.8 kB CSS (0) | — |
| lab/ChatReactionBar | 103.9 kB (+441 B) · 1.1 kB CSS (0) | — |
| lab/PageControl | 73.5 kB (+429 B) · 709 B CSS (0) | — |
| lab/TourStep | 94.6 kB (+409 B) · 590 B CSS (0) | — |
| ContextMenu | 106.2 kB (+1 B) · 17.0 kB CSS (0) | — |
| Pagination | 108.3 kB (+1 B) · 17.5 kB CSS (0) | — |
| Table | 116.3 kB (+1 B) · 17.7 kB CSS (0) | — |
| Markdown | 179.5 kB (0) · 20.0 kB CSS (0) | — |
| MoreMenu | 95.9 kB (0) · 17.1 kB CSS (0) | — |
| MultiSelector | 93.4 kB (0) · 16.6 kB CSS (0) | — |
| Selector | 98.2 kB (0) · 17.1 kB CSS (0) | — |
| TableHeaderCell | 107.0 kB (0) · 17.2 kB CSS (0) | — |
| Tokenizer | 90.1 kB (0) · 18.4 kB CSS (0) | — |
| lab/TabBarItem | 3.8 kB (0) · 1.8 kB CSS (0) | — |
| richtext/RichTextEditorToolbar | 250.8 kB (0) · 454 B CSS (0) | — |
| DropdownMenu | 95.6 kB (−1 B) · 17.1 kB CSS (0) | — |
| TableCell | 107.4 kB (−1 B) · 17.4 kB CSS (0) | — |
Package size: @astryxdesign/core 7.00 MB packed (+3.6 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 29 rows, core 35 rows; run pnpm api:report.
Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes: the settle copies cut the release's work and keep the items in step (the new frame checks pass on this head and fail on main), but they run beside the shared animator instead of through it.
SnapPaging.tsplays every item after the first through local Web Animations copies (startedOn,copyToChildren,alignToLead) that re-implement the animator's start dating outside its start group and skip its layer promotion, so on an edge-button press from rest the copied items get nowill-changefor the whole settle; extend the animator so oneplaybakes once and drives several targets, and call that instead.
Two optional comment wording suggestions are inline.
[Automated review]
f6b17a5 to
fba753c
Compare
There was a problem hiding this comment.
Requesting changes: the settle now bakes once inside the shared animator and every item keeps its own animator, start and layer, which settles the earlier copy-path concern, but the new keyframe cache misses one case.
rebasekeeps a played curve'ssourcewhen it shifts the segment (the non-spring branch inmotion/animator.ts), and the new task-bake key compares onlysource, offset and duration, so a curve that is played and rebased in the same task replays its unshifted keyframes and then jumps by the rebase delta when it retires; droppingsourcefrom the rebased segment and adding a unit test that plays and rebases in one task fixes it.
This review covers the whole diff against main, #10584's commits included, because #10584's description does not carry the same Stack: line. Two optional comment wording suggestions are inline.
[Automated review]
fba753c to
dd2bc6e
Compare
There was a problem hiding this comment.
Requesting changes: the rebase fix and both comment suggestions are in, and the settle now bakes once while every item keeps its own animator, but leaving items out of the settle breaks how the row is measured while it settles.
- Miss: a second flick that lands on a running settle makes the pager remeasure the row while the left-out items still sit at their release translate, so
span(),spansOf()and the stops read inSnapPaging.tssee their edges off by the distance the lead has moved, and on the three-up story two flicks toward the end rest on items 6–8 or back on items 1–3 instead of a view page (main rests on a page every time); measuring each item net of its own translate relative to the lead, or placing the left-out items at the lead beforemeasurePagesreads them, plus a settle-spec case that flicks again mid-settle, would fix it.
[Automated review]
A settle played the pager's curve on every item, and each item's animator sampled the same curve into the same keyframes. The animator now reuses the keyframes that an earlier call of the same task baked for the same curve objects, offset and rest values, and copies their effect. With other rest values it reuses only the sample times. Snap paging plays the settle on the lead and on the items that can show during it, and a stop puts every item of a held row where the lead stopped. Before the row is measured, the items the settle left out take the lead's translate. The three-up paging story takes hasLoop, so a press past the last page sweeps every page.
dd2bc6e to
bdfb6b8
Compare
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet; it runs once the pull request leaves draft and a maintainer adds the ci:run label.
A second flick during a settle now rests on a view page, as it does on main, and the shared bake, the culling and the catch alignment hold in right-to-left, under Reduce Motion and through a resize mid-settle. One non-blocking comment wording suggestion is inline.
[Automated review]
SnapPaging.ts takes main's end-page skip and pages(): stops() aligns the items a settle left out, then reads pages().stops.
|
/approve-spec f579ad9 |
There was a problem hiding this comment.
Approved: this head only merges main and takes the last comment suggestion, and the settle bake and culling still hold beside main's split-end pages, in both directions and through a touch that catches a settle.
CI's WebKit interaction shard 1/6 is red on two tests: this change's widened-row settle test hit the harness's frame-starvation error (no frame for 555 ms, which the harness says proves nothing), and a harness test that main has since updated failed. The widened-row test passes 10 of 10 in WebKit on this head and every other shard is green, so please update the branch onto main and re-run that shard; the pull request can merge once the required checks pass.
[Automated review]
|
/approve-spec 503b493 |
There was a problem hiding this comment.
Approved: the head only merges main, which changes none of this pull request's files, and CI is green on it.
The settle proofs pass on main's reworked touch harness in Chromium and WebKit, including the WebKit interaction shard that failed before.
[Automated review]
User impact
A snap-paging Carousel's lift took 36.2 ms of main thread at 4× CPU with 9 items (two dropped frames on a low-end phone), 66.2 ms with 30; UIKit's takes none.
Problem and solution fit
Every item's animator sampled the pager's curve into the same keyframes: 3,710 curve reads per settle with 9 items, 12,320 with 30. Now a call reuses keyframes an earlier call in its task baked from the same curve objects, offset and rest values, or else only their sample times. Snap paging plays the settle only on the lead and items that can show.
Expected behavior and authority
spec:AST-094FR5: a release advances at display rate on the compositor;component:CarouselFR7 settles as FR6 says.Smallest restoration
animator.ts: a per-task cache of baked keyframes and sample times, keyed byplay's curve objects; a hit copies its effect, and each item keeps its own animator.SnapPaging: which items can show comes from the curve and the items' spans, re-read on a resize under a held finger. A measure or a stop puts the other items where the lead is.hasLoop.Evidence
Reproduction before the change: on the base arm, 9 bakes per settle; a caught row leaves items apart.
Result after the change: 1 bake, 490 curve reads per settle, with 9 or 30 items. Every item in view animates on its own layer, from the lead's start and at its translate; a caught row puts each at the lead's translate.
Regression test or other mutation-sensitive proof: seven mutants each fail their test, and the copies head fails the layer check.
Cost, the lift's task in Chromium, median of 5:
Over a frame at 4×; flat in item count.
Representative unchanged path: the drag, and Reduce Motion's resting stop (items out of view skip their cross-fade).
Scope
Testing
SnapPaging.tstakes main's end-page skip (fix(SnapPaging): a stop within half a step of the end is the end page #10591), andstops()aligns the left-out items, then readspages().stops. At that head: the settle spec ×3, Chromium 24 of 24 and WebKit 24 of 24; fix(SnapPaging): a stop within half a step of the end is the end page #10591's SnapPaging spec, Chromium 43 passed and 5 skipped, WebKit 48 passed; Carousel and SnapPaging specs, Chromium 59 passed and 5 skipped, WebKit 63 passed and 1 skipped; units 2,073; typecheck 0; strict lint 0 errors. The results below are at bdfb6b8, before the merge.pnpm test:ui): 920 files, 22,570 tests pass.will-change: translate, and each item in view is within 0.01 px of the lead's translate. WebKit reads an accelerated animation at each read's own time, so the check reads the lead before and after the items and skips a frame whose lead moved.atcall on the pager's curve (main's arm); the lift's touchend task from a trace, 5 runs each, 30 items cloned from the story's 9; Reduce Motion's settle, 2 runs each.CI=true pnpm lint0 errors;pnpm check:knowledgepasses; Changeset coverage passes.