Repository navigation
perf(core): read a list's animations once per hit-area pass - #13124
Conversation
Under a coarse pointer, a touch hit area waits out its parent's motion before it writes its insets. The shared pass wrote its rows one at a time, and each row read its parent's animations with getAnimations. That read recalculates the styles that the row before it changed. So a list of N rows read the same list N times, with N style recalculations. Each loop of writes now gets one read per root, which deliver passes to the watch's callback. A write of hit insets starts no animation, so each row gets the list that its own read would find, and makes the same decision. A callback that gets no read, such as a test's stand-in for the watch, reads at once. Tests: a pass over two lists of 12 and 3 rows reads each list once, where main reads them 12 and 3 times. A row whose own list slides still waits and is written when the slide ends. The rows of a list at rest are written at once.
|
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 |
|---|---|---|
| Pagination | 153.3 kB (+89 B) · 20.0 kB CSS (0) | — |
| lab/PageControl | 79.0 kB (+78 B) · 709 B CSS (0) | — |
| AppShell | 100.9 kB (+72 B) · 14.9 kB CSS (0) | — |
105 more components
| Component | Size | LoC |
|---|---|---|
| richtext/RichTextEditorToolbar | 315.1 kB (+71 B) · 454 B CSS (0) | — |
| DialogHeader | 70.9 kB (+69 B) · 12.8 kB CSS (0) | — |
| AlertDialog | 133.1 kB (+68 B) · 16.2 kB CSS (0) | — |
| BreadcrumbItem | 102.5 kB (+67 B) · 14.0 kB CSS (0) | — |
| ButtonGroup | 44.8 kB (+66 B) · 3.7 kB CSS (0) | — |
| Carousel | 77.7 kB (+66 B) · 12.1 kB CSS (0) | — |
| lab/DialogHeroHeader | 92.2 kB (+66 B) · 372 B CSS (0) | — |
| lab/TransferListSelector | 151.0 kB (+66 B) · 1.4 kB CSS (0) | — |
| ToggleButton | 94.9 kB (+65 B) · 11.3 kB CSS (0) | — |
| BaseTypeahead | 83.9 kB (+63 B) · 12.1 kB CSS (0) | — |
| ChatComposer | 90.7 kB (+63 B) · 13.5 kB CSS (0) | — |
| TimeInput | 180.3 kB (+63 B) · 17.8 kB CSS (0) | — |
| Typeahead | 94.9 kB (+63 B) · 14.4 kB CSS (0) | — |
| Thumbnail | 72.1 kB (+62 B) · 12.7 kB CSS (0) | — |
| TopNav | 81.0 kB (+61 B) · 12.1 kB CSS (0) | — |
| Button | 67.6 kB (+60 B) · 11.1 kB CSS (0) | — |
| Markdown | 208.5 kB (+60 B) · 23.4 kB CSS (0) | — |
| TableHeaderCell | 106.2 kB (+60 B) · 20.0 kB CSS (0) | — |
| TopNavMenu | 87.2 kB (+60 B) · 12.4 kB CSS (0) | — |
| lab/MediaCaptionsButton | 223.2 kB (+60 B) · 1.5 kB CSS (0) | — |
| lab/MediaFullscreenButton | 223.2 kB (+60 B) · 1.5 kB CSS (0) | — |
| lab/MediaPlaybackRate | 223.2 kB (+60 B) · 1.5 kB CSS (0) | — |
| lab/MediaSeekButton | 223.2 kB (+60 B) · 1.5 kB CSS (0) | — |
| lab/MediaVolume | 223.2 kB (+60 B) · 1.5 kB CSS (0) | — |
| lab/SelectableCardGroup | 71.5 kB (+60 B) · 162 B CSS (0) | — |
| Banner | 69.7 kB (+59 B) · 11.6 kB CSS (0) | — |
| FileInput | 77.4 kB (+59 B) · 12.8 kB CSS (0) | — |
| NumberInput | 106.1 kB (+59 B) · 13.0 kB CSS (0) | — |
| RadioList | 62.5 kB (+59 B) · 7.6 kB CSS (0) | — |
| lab/MediaPlayButton | 223.2 kB (+59 B) · 1.5 kB CSS (0) | — |
| lab/MediaTime | 223.2 kB (+59 B) · 1.5 kB CSS (0) | — |
| lab/MediaTimeSlider | 223.2 kB (+59 B) · 1.5 kB CSS (0) | — |
| CheckboxInput | 71.0 kB (+58 B) · 10.6 kB CSS (0) | — |
| SideNavItem | 82.4 kB (+58 B) · 12.3 kB CSS (0) | — |
| TableSelectionToolbar | 78.1 kB (+58 B) · 14.5 kB CSS (0) | — |
| ChatLayout | 91.2 kB (+57 B) · 11.7 kB CSS (0) | — |
| CheckboxListItem | 82.0 kB (+57 B) · 12.5 kB CSS (0) | — |
| MoreMenu | 113.5 kB (+57 B) · 19.8 kB CSS (0) | — |
| PowerSearch | 318.1 kB (+57 B) · 27.3 kB CSS (0) | — |
| lab/Schedule | 117.7 kB (+57 B) · 3.9 kB CSS (0) | — |
| richtext/RichTextEditor | 310.8 kB (+57 B) · 2.7 kB CSS (0) | — |
| richtext/RichTextView | 287.5 kB (+57 B) · 2.4 kB CSS (0) | — |
| Calendar | 78.8 kB (+56 B) · 11.8 kB CSS (0) | — |
| Switch | 111.1 kB (+56 B) · 10.4 kB CSS (0) | — |
| Table | 124.2 kB (+56 B) · 21.1 kB CSS (0) | — |
| TableCell | 106.3 kB (+56 B) · 20.1 kB CSS (0) | — |
| TabMenu | 84.3 kB (+56 B) · 12.3 kB CSS (0) | — |
| lab/TabBarMoreList | 104.2 kB (+56 B) · 1.8 kB CSS (0) | — |
| lab/TourStep | 96.7 kB (+56 B) · 691 B CSS (0) | — |
| InputGroup | 63.2 kB (+55 B) · 8.8 kB CSS (0) | — |
| MobileNav | 79.1 kB (+55 B) · 11.8 kB CSS (0) | — |
| MultiSelector | 109.0 kB (+55 B) · 18.9 kB CSS (0) | — |
| TextArea | 94.6 kB (+55 B) · 10.0 kB CSS (0) | — |
| ToggleButtonGroup | 42.0 kB (+55 B) · 3.7 kB CSS (0) | — |
| lab/TransferList | 139.1 kB (+55 B) · 1.2 kB CSS (0) | — |
| IconButton | 67.6 kB (+54 B) · 11.1 kB CSS (0) | — |
| Popover | 104.3 kB (+54 B) · 15.5 kB CSS (0) | — |
| RadioListItem | 78.1 kB (+54 B) · 11.1 kB CSS (0) | — |
| lab/Comments | 388.4 kB (+54 B) · 2.5 kB CSS (0) | — |
| lab/DiffViewer | 95.9 kB (+54 B) · 2.1 kB CSS (0) | — |
| ChatDictationButton | 68.2 kB (+53 B) · 11.2 kB CSS (0) | — |
| Lightbox | 151.2 kB (+53 B) · 12.3 kB CSS (0) | — |
| ChatLayoutScrollButton | 68.2 kB (+52 B) · 11.3 kB CSS (0) | — |
| DateTimeInput | 232.0 kB (+52 B) · 20.6 kB CSS (0) | — |
| ChatSendButton | 68.0 kB (+51 B) · 11.1 kB CSS (0) | — |
| ContextMenu | 105.1 kB (+51 B) · 19.6 kB CSS (0) | — |
| Field | 61.0 kB (+51 B) · 7.6 kB CSS (0) | — |
| SegmentedControlItem | 19.2 kB (+51 B) · 4.3 kB CSS (0) | — |
| Toast | 107.4 kB (+51 B) · 11.5 kB CSS (0) | — |
| lab/ChatReactionBar | 129.0 kB (+51 B) · 1.1 kB CSS (0) | — |
| lab/CommentThread | 381.3 kB (+51 B) · 2.4 kB CSS (0) | — |
| lab/VideoPlayer | 231.0 kB (+51 B) · 2.1 kB CSS (0) | — |
| Tokenizer | 112.9 kB (+50 B) · 21.9 kB CSS (0) | — |
| FieldLabel | 56.9 kB (+49 B) · 6.1 kB CSS (0) | — |
| SideNavCollapseButton | 68.5 kB (+49 B) · 11.2 kB CSS (0) | — |
| Stepper | 69.4 kB (+49 B) · 11.3 kB CSS (0) | — |
| lab/ListInput | 97.2 kB (+49 B) · 922 B CSS (0) | — |
| ComplexSelector | 83.7 kB (+48 B) · 13.2 kB CSS (0) | — |
| Slider | 116.2 kB (+48 B) · 9.2 kB CSS (0) | — |
| TopNavHeading | 87.7 kB (+48 B) · 12.4 kB CSS (0) | — |
| TopNavMegaMenu | 81.7 kB (+47 B) · 13.0 kB CSS (0) | — |
| DropdownMenu | 113.2 kB (+46 B) · 19.8 kB CSS (0) | — |
| MobileNavToggle | 67.9 kB (+46 B) · 11.1 kB CSS (0) | — |
| lab/ChatEmojiPicker | 127.8 kB (+46 B) · 773 B CSS (0) | — |
| CheckboxList | 74.7 kB (+45 B) · 8.1 kB CSS (0) | — |
| SideNav | 124.0 kB (+45 B) · 12.5 kB CSS (0) | — |
| lab/CommentComposer | 186.5 kB (+45 B) · 1.9 kB CSS (0) | — |
| DateInput | 208.1 kB (+44 B) · 18.9 kB CSS (0) | — |
| ChatComposerTokenElement | 87.8 kB (+43 B) · 12.5 kB CSS (0) | — |
| DrawerHeader | 71.0 kB (+43 B) · 14.3 kB CSS (0) | — |
| Selector | 120.1 kB (+43 B) · 19.7 kB CSS (0) | — |
| ChatComposerInput | 87.8 kB (+42 B) · 12.5 kB CSS (0) | — |
| ListItem | 81.1 kB (+41 B) · 12.5 kB CSS (0) | — |
| SideNavHeading | 88.0 kB (+39 B) · 12.5 kB CSS (0) | — |
| lab/EmojiPicker | 120.9 kB (+39 B) · 751 B CSS (0) | — |
| CodeBlock | 83.7 kB (+38 B) · 12.9 kB CSS (0) | — |
| DateRangeInput | 106.1 kB (+38 B) · 14.2 kB CSS (0) | — |
| InfoTip | 51.9 kB (+35 B) · 5.7 kB CSS (0) | — |
| lab/AudioPlayer | 233.4 kB (+35 B) · 1.8 kB CSS (0) | — |
| TextInput | 101.2 kB (+31 B) · 12.8 kB CSS (0) | — |
| OverflowList | 12.6 kB (0) · 3.7 kB CSS (0) | — |
| SegmentedControl | 103.5 kB (0) · 7.2 kB CSS (0) | — |
| Timestamp | 31.2 kB (0) · 11.4 kB CSS (0) | — |
| lab/TabBar | 84.5 kB (0) · 1.8 kB CSS (0) | — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — |
Package size: @astryxdesign/core 7.92 MB packed (+712 B); no new dependencies.
Not run on this PR: add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. This is a draft from a fork, so CI starts once it is marked ready for review and a maintainer adds the ci:run label.
The hit-area pass now reads each list's animations once per loop of writes, and every row keeps its decision: the new count test fails on main (12 and 3 reads) and passes here (1 and 1), and the decisions test passes on both. There are no blocking findings.
- Optional:
touchHitArea.pass.test.tsxneeds all 15 rows written in one pass but leaves the 4 ms frame budget on the real clock; holding it still withvi.spyOn(performance, 'now').mockReturnValue(0)(restored inafterEach), ashitArea.test.tsdoes, stops a slow runner from splitting the batch.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Changeset: a list's hit areas update with one read of the list's animations, not one per row. Verified by the new count test (12 and 3 reads before, 1 and 1 after).
- Changeset: the page no longer recalculates styles once per written row. Verified: reads of one list no longer interleave with its rows' writes (
hitArea.ts:797-807,:913-916). - Description: before, each row read its list's animations. Verified in the base
touchHitArea.ts. - Description: after, each loop of writes reads each list once and shares that read. Verified (
hitArea.ts:913-916,:1354-1357). - Description: insets and wait decisions are unchanged because neither reader of the insets has a transition. Verified (
internal/touchHitArea.stylex.ts,Switch.tsx:337-349; the decisions test passes on both trees). - Description: what changed in
hitArea.ts,touchHitArea.tsand the changeset. Verified against the diff. - Description: 51 against 2
getAnimationscalls for a 50-row pass. Consistent with the code; the browser timings were not rerun. - Description: red first and same decisions. Verified by rerunning the new file against
main. - Description: #11205 removes this path, and #13009's hunks do not overlap. Verified from both pull requests' files.
- Description: the listed components reach the change through the two utilities. Verified from their imports.
- Description: no public API change and no internal context. Verified (no API surface row changes; no internal reference in the added text).
- Description: 2/2, 76/76 and 4183/4183 tests, shared identity 7/7, typecheck, ESLint, Prettier and the changeset check. Verified by rerunning; the Chromium and WebKit interaction specs were not rerun.
- Description: reference-page sizes docs +0, form +75, menu +50 and table +60 B gzip. Verified within 3 B (+0, +75, +47, +61).
.changeset/hit-area-one-animation-read.md: clear.packages/core/src/utils/hitArea.ts: clear.packages/core/src/utils/touchHitArea.ts: clear.packages/core/src/utils/touchHitArea.pass.test.tsx: the optional clock note above.
| frames.push(run); | ||
| return frames.length; | ||
| }); | ||
| vi.stubGlobal('cancelAnimationFrame', () => {}); |
There was a problem hiding this comment.
Optional: the count case needs all 15 rows written in one pass, but the pass's 4 ms frame budget still reads the real clock, so a stalled runner can split the batch and fail the case. Holding the clock still here, vi.spyOn(performance, 'now').mockReturnValue(0); with vi.restoreAllMocks() in afterEach, as hitArea.test.ts does, removes that risk.
|
/approve-spec df7ed84 |
|
/approve-spec 02aa339 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. This is a draft from a fork, so CI starts once it is marked ready for review and a maintainer adds the ci:run label.
The merge of main leaves this pull request's own patch unchanged. The hit-area pass still reads each list's animations once per loop of writes, and every row keeps its decision: the count test fails on main (12 and 3 reads) and passes here (1 and 1), and the decisions test passes on both. There are no blocking findings.
- Optional, still open:
touchHitArea.pass.test.tsxneeds all 15 rows written in one pass but leaves the 4 ms frame budget on the real clock; holding it still withvi.spyOn(performance, 'now').mockReturnValue(0)(restored inafterEach), ashitArea.test.tsdoes, stops a slow runner from splitting the batch.
Claims and files checked
Review mode: incremental; reason: none
- Changed rules (0): none.
- Changeset: a list's hit areas update with one read of the list's animations, not one per row. Verified by the new count test (12 and 3 reads before, 1 and 1 after).
- Changeset: the page no longer recalculates styles once per written row. Verified: reads of one list no longer interleave with its rows' writes (
hitArea.ts:837-847,:953-955). - Description: before, each row read its list's animations. Verified in the base
touchHitArea.ts. - Description: after, each loop of writes reads each list once and shares that read. Verified (
hitArea.ts:953-955,:1395-1397). - Description: insets and wait decisions are unchanged because neither reader of the insets has a transition. Verified (
internal/touchHitArea.stylex.ts,Switch.tsx:337-350; the decisions test passes on both trees). - Description: what changed in
hitArea.ts,touchHitArea.tsand the changeset. Verified against the diff. - Description: 51 against 2
getAnimationscalls for a 50-row pass. Consistent with the code; the browser timings were not rerun. - Description: red first and same decisions. Verified by rerunning the new file against this base.
- Description: #11205 removes this path, and #13009's hunks do not overlap. Verified: #11205 deletes most of
hitArea.ts; #13009 has landed and merged in without conflict. - Description: the listed components reach the change through the two utilities. Verified from their imports.
- Description: no public API change and no internal context. Verified (no API surface row changes; no internal reference in the added text).
- Description: test, typecheck, lint, format, changeset and shared-identity results. Verified at this head; the unit totals are now higher (85 and 4210, all passing) after the merge of
main; the Chromium and WebKit interaction specs were not rerun. - Description: reference-page sizes docs +0, form +75, menu +50 and table +60 B gzip. Verified within 7 B at this base (+0, +74, +51, +53).
.changeset/hit-area-one-animation-read.md: clear.packages/core/src/utils/hitArea.ts: clear.packages/core/src/utils/touchHitArea.ts: clear.packages/core/src/utils/touchHitArea.pass.test.tsx: the optional clock note above.
|
/approve-spec 6284299 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. This is a draft from a fork, so CI starts once it is marked ready for review and a maintainer adds the ci:run label.
The new merge of main leaves this pull request's own patch and every file it changes untouched. The hit-area pass still reads each list's animations once per loop of writes, every row keeps its decision, and there are no blocking findings.
- Optional, still open:
touchHitArea.pass.test.tsxneeds all 15 rows written in one pass but leaves the 4 ms frame budget on the real clock; holding it still withvi.spyOn(performance, 'now').mockReturnValue(0)(restored inafterEach), ashitArea.test.tsdoes, stops a slow runner from splitting the batch.
Claims and files checked
Review mode: carry-forward; reason: none
- Changeset: a list's hit areas update with one read of the list's animations, not one per row. Verified by the new count test (12 and 3 reads before, 1 and 1 after).
- Changeset: the page no longer recalculates styles once per written row. Verified: reads of one list no longer interleave with its rows' writes (
hitArea.ts:837-847,:953-955). - Description: before, each row read its list's animations. Verified in the base
touchHitArea.ts. - Description: after, each loop of writes reads each list once and shares that read. Verified (
hitArea.ts:953-955,:1395-1397). - Description: insets and wait decisions are unchanged because neither reader of the insets has a transition. Verified (
internal/touchHitArea.stylex.ts,Switch.tsx:337-350; the decisions test passes with and without the change). - Description: what changed in
hitArea.ts,touchHitArea.tsand the changeset. Verified against the diff. - Description: 51 against 2
getAnimationscalls for a 50-row pass. Consistent with the code; the browser timings were not rerun. - Description: red first and same decisions. Verified by running the new file without the change.
- Description: #11205 removes this path, and #13009's hunks do not overlap. Verified: #11205 deletes most of
hitArea.ts; #13009 has landed and merged in without conflict. - Description: the listed components reach the change through the two utilities. Verified from their imports.
- Description: no public API change and no internal context. Verified (no API surface row changes; no internal reference in the added text).
- Description: test, typecheck, lint, format, changeset and shared-identity results. Verified with the same patch (85 hit-area and 4210 caller tests, all passing); the Chromium and WebKit interaction specs were not rerun.
- Description: reference-page sizes docs +0, form +75, menu +50 and table +60 B gzip. Verified within 7 B (+0, +74, +51, +53).
.changeset/hit-area-one-animation-read.md: clear.packages/core/src/utils/hitArea.ts: clear.packages/core/src/utils/touchHitArea.ts: clear.packages/core/src/utils/touchHitArea.pass.test.tsx: the optional clock note above.
User impact
getAnimations({subtree: true}). Each read also recalculated the styles that the previous row's write changed. So a list of N rows read the same list N times in one frame, with N style recalculations.What changed
utils/hitArea.ts:readOncePerRoot()makes asettlingAnimationsread that keeps each root's result. The pass's write loop and the pointer-change loop each make one, anddeliverpasses it to the watch'sonInsets.utils/touchHitArea.ts: the watch's callback uses that read. A callback that gets no read, such as a test's stand-in for the watch, reads at once.[perf]changeset.Evidence
One pass writes new insets to the 50 rows of one list. Chromium 149 emulates a phone's touch screen. Median of 31 passes, two runs each (test data):
getAnimationscallsmain4a1bc36On
main, the pass reads the document once and the list once for each row. Here it reads the document and the list once each. The page is light.touchHitArea.pass.test.tsxrenders lists of 12 and 3 rows with the real pass, and counts each list'sgetAnimationscalls.mainreads them 12 and 3 times, and this change once each.mainand here.Other pull requests
hitArea.ts, inreadCandidates,measureOneandisNearerNeighbour. Their hunks do not overlap.Scope
Components: AlertDialog, Button, ButtonGroup, CheckboxInput, InfoTip, Lightbox, List, RadioList, SegmentedControl, Switch, ToggleButton, ToggleButtonGroup, and Lab's PageControl (through
utils/hitArea.tsandutils/touchHitArea.ts)watchHitAreaanduseTouchHitAreaare internal.Testing
touchHitArea.pass.test.tsx: 2 of 2 pass. Onmain, the count case fails and the decisions case passes.hitArea.test.ts,touchHitArea.test.tsxand the new file: 76 of 76 pass.utils,hooks,internal,AlertDialog,Button,ButtonGroup,CheckboxInput,Field,Indicator,InfoTip,Lightbox,List,RadioList,SegmentedControl,Switch,ToggleButton, LabPageControl): 4183 of 4183 pass.hitArea,ButtonHitArea,TouchTargets,ListTouchHitArea,SegmentedControlHitArea): 35 of 35 pass in Chromium and 35 of 35 in WebKit.scripts/shared-identity.test.mjs: 7 of 7 pass. No module state is added.check:changesets.pnpm size:pagesagainstmain4a1bc36, first-load gzip: docs +0 B, form +75 B, menu +50 B and table +60 B. This is a report for a change to shared modules, asarchitecture:component-import-boundariesINV10 asks.