Skip to content

perf(core): motions one callback starts read stylesheets in one pass - #10728

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:perf/motion-promotions-one-style-pass
Nov 9, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:perf/motion-promotions-one-style-pass

Conversation

@vjeux

@vjeux vjeux commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

User impact

One callback can start motions on elements that came in the same task. The animator then forced a style pass per element there: eight for eight rows that glide together, two on a list reorder's first key move.

Problem and solution fit

  • An element's first promotion keeps its stylesheet's will-change beside the animator's, so the animator reads that stylesheet once.
  • For an element that came in the same task, that read ran in the element's own call, right after the call wrote its translate. So every element forced a style pass.
  • The promotion is still written in the task that starts the motion. Its stylesheet's reasons now join it in one microtask after the callback, shared by every animator. That microtask takes the promotions off, reads every stylesheet, then writes the promotions back.

Expected behavior and authority

architecture:react-component-runtime INV18: a read happens "in one batched measurement pass per change, never interleaved with writes", and its review row fails "a read interleaved with writes".

Smallest restoration

  • writePromotion writes the promoted channels at once and queues the stylesheet read when it is unread (queueSheetRead, flushSheetReads).
  • Unchanged: an element whose stylesheet an earlier task read, an inline will-change, and a pseudo-element's promotion.
  • The List reorder proof drops its allowance of one pass per row that glides for the first time. component:List PR2 drops that pass as an implementation gap.

Evidence

  • Before: eight new rows animated in one callback forced 8 style passes in it (Chromium trace, 3 of 3 runs). A List reorder's first key move counted 2 animator passes (3 of 3).
  • After: 1 style pass (8 of 8 runs), with each row's stylesheet reason kept (opacity, translate). The key move counts at most 1 (3 of 3).
  • Unchanged: an element whose stylesheet an earlier task read still promotes with no read in its own task (the existing unit case). The List's move back still counts at most one pass.
  • Mutation-sensitive: on main's animator (40d94c07ac), the new unit case, the trace case and the List pass count fail.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Unit, on 1ac16e3: the motion folder (1,004 tests); core's ui project (21,047 tests); core TypeScript (rc 0). At this head, the motion and List units pass (1,199). Three existing cases that read the stylesheet's reasons now wait a microtask for them.
  • Browser, every interaction spec on 1ac16e3, from which this head changes one comment and the List record. Chromium 1,447 passed, 34 skipped; WebKit at CI's settings 1,247 passed, 232 skipped. Two WebKit runs failed by name as starved of frames on a loaded box (TextField focus timing, TabBar's lens). Both then passed 3 of 3, as on main's animator.
  • Dependent audits: 205 of 205, in Chromium, on a Storybook built and stamped at 1ac16e3. They are the 14 audit spec files of the 22 Core folders that import the animator.
  • Android exit timing (storybook-delete): main none/71 ms, head none/64 ms (6 interleaved rounds; medians; main worst gap 89 ms), on 1ac16e3
  • Android exit timing (alert-over-a-toast): main none/100 ms, head none/92 ms (6 interleaved rounds; medians; main worst gap 216 ms), on 1ac16e3
  • ESLint, Prettier, check:knowledge and check:changesets.

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 9, 2026 1:45am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 9, 2026
@astracat-bot

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 2:01 AM UTC

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9bce3d7

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
TimeInput 162.0 kB (+211 B) · 16.0 kB CSS (0) — — · — · —
BottomSheet 67.9 kB (+171 B) · 7.7 kB CSS (0) — — · — · —
lab/PageControl 75.2 kB (+167 B) · 709 B CSS (0) — — · — · —
34 more components
Component Size LoC Visual · A11y · RTL
SideNav 114.2 kB (+162 B) · 11.4 kB CSS (0) — — · — · —
ChatLayout 83.0 kB (+156 B) · 10.5 kB CSS (0) — — · — · —
DateTimeInput 208.2 kB (+154 B) · 18.7 kB CSS (0) — — · — · —
lab/TabBar 76.9 kB (+154 B) · 1.8 kB CSS (0) — — · — · —
PowerSearch 286.7 kB (+152 B) · 24.1 kB CSS (0) — — · — · —
SegmentedControl 96.2 kB (+152 B) · 6.9 kB CSS (0) — — · — · —
lab/CommentComposer 151.1 kB (+141 B) · 1.9 kB CSS (0) — — · — · —
lab/Comments 350.1 kB (+139 B) · 2.5 kB CSS (0) — — · — · —
lab/ChatReactionBar 106.9 kB (+138 B) · 1.1 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 105.7 kB (+136 B) · 773 B CSS (0) — — · — · —
lab/NavigationStack 82.2 kB (+134 B) · 1.5 kB CSS (0) — — · — · —
lab/NavigationScreen 82.2 kB (+133 B) · 1.5 kB CSS (0) — — · — · —
Slider 109.3 kB (+129 B) · 8.8 kB CSS (0) — — · — · —
DateInput 186.5 kB (+128 B) · 17.0 kB CSS (0) — — · — · —
Switch 103.8 kB (+126 B) · 9.9 kB CSS (0) — — · — · —
lab/CommentThread 343.2 kB (+126 B) · 2.4 kB CSS (0) — — · — · —
lab/TourStep 97.4 kB (+122 B) · 590 B CSS (0) — — · — · —
Lightbox 122.5 kB (+121 B) · 10.6 kB CSS (0) — — · — · —
Popover 91.0 kB (+115 B) · 14.2 kB CSS (0) — — · — · —
TableCell 109.6 kB (+1 B) · 17.9 kB CSS (0) — — · — · —
DropdownMenu 97.2 kB (0) · 17.6 kB CSS (0) — — · — · —
List 18.0 kB (0) · 790 B CSS (0) — ✓ · ✓ · —
ListItem 70.4 kB (0) · 11.4 kB CSS (0) — ✓ · ✓ · ✓
Markdown 187.3 kB (0) · 20.6 kB CSS (0) — — · — · —
MoreMenu 97.5 kB (0) · 17.6 kB CSS (0) — — · — · —
MultiSelector 94.9 kB (0) · 16.8 kB CSS (0) — — · — · —
Pagination 109.8 kB (0) · 17.8 kB CSS (0) — — · — · —
Selector 99.8 kB (0) · 17.4 kB CSS (0) — — · — · —
Table 124.6 kB (0) · 18.3 kB CSS (0) — — · — · —
TableHeaderCell 109.2 kB (0) · 17.7 kB CSS (0) — — · — · —
Tokenizer 91.5 kB (0) · 18.8 kB CSS (0) — — · — · —
lab/TabBarItem 3.8 kB (0) · 1.8 kB CSS (0) — — · — · —
ContextMenu 108.3 kB (−1 B) · 17.4 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 277.9 kB (−1 B) · 454 B CSS (0) — — · — · —

Package size: @astryxdesign/core 7.19 MB packed (+1.1 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 34 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 9, 2026

@astracat-bot astracat-bot 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.

Approved pending CI: CI has not run on this head yet. The pull request is a draft, so marking it ready for review starts its run (it already carries ci:run).

The animator now reads fresh promotions' stylesheets in one batched style pass per callback (architecture:react-component-runtime INV18): eight new rows drop from 8 forced passes to 1, List's first reorder key move from 2 animator passes to 1, and both new proofs fail against main's animator. Rendered output, the public API and the compositor run through a blocked main thread are unchanged.

Non-blocking:

  • component:List PR2 in docs/specs/components/List/List.spec.md still lists the per-row style pass as an implementation gap; consider removing that sentence here or in a follow-up.
  • The read comment at packages/core/src/motion/animator.ts:816 restates its name; consider dropping it.

[Automated review]

Comment thread packages/core/src/motion/animator.ts Resolved
An element's first promotion keeps its stylesheet's will-change beside
the animator's. For an element that came in the same task, the
animator read that stylesheet at once, right after writing the
element's translate, so each element forced a style pass: eight for a
list whose eight rows glide together.

The promotion is still written in the task that starts the motion.
Its stylesheet's reasons now join it in one microtask after the
callback, shared by every animator: it takes the promotions off, reads
every stylesheet, then writes the promotions back. So the motions that
one callback starts force one style pass.

The List reorder proof drops its allowance of one pass per row that
glides for the first time, and component:List PR2 drops that pass as
an implementation gap.
@vjeux
vjeux force-pushed the perf/motion-promotions-one-style-pass branch from 1ac16e3 to 9bce3d7 Compare November 9, 2026 01:39
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 9, 2026
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 9bce3d7

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 9, 2026

@astracat-bot astracat-bot 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.

Approved pending CI: CI has not run on this head yet. The pull request is a draft, so marking it ready for review starts its run (it already carries ci:run).

The animator now reads the stylesheets of not-yet-read promotions in one batched style pass per callback (architecture:react-component-runtime INV18): eight fresh rows go from 8 style passes to 1 and the List's first key move from 2 animator passes to 1, and both proofs fail against the base. Both earlier notes are addressed (the restating comment is gone and component:List PR2 no longer records the gap), and an engineering owner has approved that record edit at this head.

[Automated review]

@vjeux
vjeux marked this pull request as ready for review November 9, 2026 02:15
@cixzhang
cixzhang merged commit df4c958 into meta:main Nov 9, 2026
131 checks passed
@vjeux
vjeux deleted the perf/motion-promotions-one-style-pass branch November 9, 2026 02:55

This branch was successfully deployed

1 active deployment
Preview — 9bce3d74 Deployed Nov 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants