Skip to content

fix(core): a layout change made late in a long task plays its motion instead of skipping past it - #9274

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/f1-layout-start-after-block
Nov 4, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/f1-layout-start-after-block

Conversation

@vjeux

@vjeux vjeux commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

User impact

On main, a layout change made late in a long task (a slow click handler) skips its motion: the side navigation's collapse snaps to its end, and under Reduce Motion its cross-fade never shows.

Problem and solution fit

  • Why it skips: a change's animations started on the timeline's time, held at the frame before a long task.
  • The fix: a change starts on that time only while the frame is at most 34 ms old (LATE_START_MS), else when its first animation is made; its glides and riding parts share that start.
  • The initial state never animates: a SideNav change before the rail first paints, other than by its own toggle, lands at once. It reads the mount frame once per nav node.
  • An edge reads the element it rides on the timeline's clock (after a block, WebKit evaluates a running translate on the live clock); a reversal's fades start where the glide carries on.

Expected behavior and authority

A block delays motion, never skips it (motion/README.md, design:reduced-motion DR2). component:SideNav FR6 and component:AppShell FR17 gain the initial-state sentence.

Smallest restoration

One start rule per change in safeAnimate; rides read the ridden glide's curve; SideNav compares the timeline's frame with its mount frame.

Evidence

  • Reproduction before the change: on main's module, 4 of the animated-layout spec's 84 Chromium cases fail (the block cases); the rail's slow-CPU Reduce Motion case fails 5 of 30. On not-for-landing red arms, the initial-state case fails 3 of 3 (e33222f), the inline-ref case fails (36bec5c), a reversal read late in its task fails in WebKit 5 of 5 (8ce9bb9), and one after a 1 s task starts its fades at 0.62/0.38/0, not 1/0/1 (91eed12).
  • Result after the change: 84 of 84; 30 of 30; 3 of 3; the inline-ref case; WebKit 20 of 20; the two reversals match, 5 of 5.
  • Representative unchanged path: a change near its frame keeps the frame time; the rail's own toggle plays before first paint.
  • Regression test or other mutation-sensitive proof: each new case fails without its fix.

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.

Writing rubric results

R1 narration: none; present tense. R2 research: none. R3 evidence: both verification rows name cases. R4 rejected alternatives: none. R5 change references: none. R6 open questions: none.

Testing

Code Quality's desktop recording at 5ce160e: Chromium passes all four conditions; the inline-ref collapse glides; WebKit shows no trail. In the reversal after a long task the fades stay in sync with the glide, and the rail's edge catches up in one frame (about 100 px), less than main's full skip.

Recording story: Core/SideNav › Inline ref collapse (core-sidenav--inline-ref-collapse): an inline ref and a button that renders the nav again, then collapses it in a later commit of the same frame.

The main arm is 1bd5870 (not for landing: main 3615956 plus this branch's animated-layout spec): 80 passed and 4 failed in Chromium, against 84 of 84 here. At this head, on one box: install, build, Storybook build, SideNav's accessibility contract (3 of 3), the module's, adopters', rail and AppShell browser specs pinned in Chromium (103 of 103) and in the CI WebKit container (92 passed, 11 skipped, 0 failed), the reversal case in WebKit 20 of 20, test:ui (19,123), check:knowledge, changesets, review:pre and lint (0 errors) all pass. The node suites pass at this head (16,120). At the previous head, 4 CLI integration files timed out under box load; this pull request touches no CLI code, and they passed on main and on that head when run again at one moment.

pnpm exec vitest run --project ui packages/core/src/motion packages/core/src/SideNav packages/core/src/AppShell
pnpm test:interaction packages/core/src/motion/__tests__/animatedLayout.interaction.browser.spec.ts packages/core/src/SideNav/__tests__/SideNavRailMotion.interaction.browser.spec.ts --project chromium

@vercel

vercel Bot commented Nov 1, 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 3, 2026 9:32pm UTC

Request Review

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

astracat-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 9:53 PM UTC

@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 5ce160e

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
AppShell · Storybook 69.2 kB (+579 B) · 12.2 kB CSS (0) 1,096 (+2) ✗ · ✓ · ✓
SideNav 66.9 kB (+718 B) · 10.9 kB CSS (0) — ✓ · ✓ · ✓
TreeList 38.4 kB (+458 B) · 5.0 kB CSS (0) — — · — · —
13 more components
Component Size LoC Visual · A11y · RTL
Collapsible 22.9 kB (+408 B) · 4.5 kB CSS (0) — — · — · —
PowerSearch 185.9 kB (+396 B) · 20.6 kB CSS (0) — — · — · —
SegmentedControl 82.2 kB (+3 B) · 7.8 kB CSS (0) — — · — · —
Switch 87.3 kB (+2 B) · 10.6 kB CSS (0) — — · — · —
DateInput 103.7 kB (0) · 15.3 kB CSS (0) — — · — · —
SideNavCollapseButton 46.3 kB (0) · 9.8 kB CSS (0) — ✓ · ✓ · ✓
SideNavHeading 58.9 kB (0) · 10.6 kB CSS (0) — ✓ · ✓ · ✓
SideNavItem 54.9 kB (0) · 10.5 kB CSS (0) — ✓ · ✓ · ✓
SideNavSection 6.6 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
TimeInput 90.5 kB (0) · 14.3 kB CSS (0) — — · — · —
DateTimeInput 159.7 kB (−2 B) · 17.1 kB CSS (0) — — · — · —
lab/MobilePowerSearch 215.2 kB (−10 B) · 1.2 kB CSS (0) — — · — · —
Slider 89.1 kB (−11 B) · 9.4 kB CSS (0) — — · — · —
Visual changes: 2 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
AppShell · Playground (neutral, dark) before frame after frame diff frame
AppShell · Playground (neutral, light) before frame after frame diff frame

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

API changes: none in this pull request

Committed API report behind this build: core 50 rows; 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 1, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 1, 2026 07:25

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

Requesting changes: the fix works on the page itself, since a layout change made after a long block now plays instead of finishing before the first frame, and the new browser case fails on main and passes here. Two things need fixing before it can merge:

  • startFor compares the global performance.now() with the element's own document timeline, so in a same-origin iframe or a Document Picture-in-Picture window every layout change starts in the future by the gap between the two documents' clocks and holds its old place (or stays at opacity 0 under Reduce Motion); read that document's own performance.now(), keep one shared start per document, and add a browser case with an iframe area.
  • The changeset and the comment in safeAnimate say the frame that draws the animations starts them, but the code starts them at the moment of the change; please reword both.

[Automated review]


function startFor(frame: number): SharedStart {
if (sharedStart?.frame !== frame) {
const now = performance.now();

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.

This compares the page's clock with element.ownerDocument's timeline. In a same-origin iframe or a Document Picture-in-Picture window the two have different time origins, so every change there takes the late path and starts in the future by the gap: in Chromium, for an iframe made 2 s after the page loaded, the row after the change held its old place (or opacity 0 under Reduce Motion) for about 2 s. Read the clock of the document whose timeline you read (document.defaultView?.performance.now()) and keep one shared start per document, e.g. a WeakMap<Document, SharedStart>.

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

Requesting changes: the per-document clock and the wording from the last round are fixed, and a layout change made after a long task now plays instead of skipping (the new browser cases fail on main, or with the page's clock, and pass here). One thing remains: the changeset and title say every late layout change now plays, but startFor shares one start per frame time, so a change made after a block that follows an earlier layout motion in the same task still starts on the pre-block frame and is over by the first frame, as on main; please word the changeset and title to match, or cover that case with a browser test. Separately and not blocking, reportLayoutEdge's measureBefore could clamp the running reveal's time at 0 like the other readers, since a late start makes it negative for the rest of its task.

[Automated review]

Comment thread .changeset/layout-start-after-block.md Outdated
'@astryxdesign/core': patch
---

[fix] A layout motion made late in a long main-thread task, such as a tap on a slow device, now plays instead of being skipped: under Reduce Motion the side navigation rail's cross-fade showed no fade at all after such a block. A layout change's animations start on the frame time the page last read only while that frame is at most 34 ms old; otherwise they start at the moment the change is made, so the block delays the motion and every part of the change still starts together.

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.

This promises every late layout change now plays, but startFor shares one start per frame time: once one layout motion of a task has started near its frame (playLayoutChange and playLayoutEdge take the start synchronously), a change made later in that task, after a block, reuses that pre-block start. In a Chromium probe, a second change made after a 1 s block started on the old frame time and was finished two frames later, as on main. Suggested wording: "…now plays instead of being skipped, unless an earlier layout motion of the same task started before the block. Every layout animation made while the page reads one frame time shares one start: that frame time if the first of them came within 34 ms of it, otherwise the moment the first was made."

@vjeux

vjeux commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 90ba1b1, rebased onto main 5909b93:

  • The start is read on the clock of the document whose timeline the animation runs on (its defaultView's performance.now()), with one shared start per document in a WeakMap. New browser case, "in a same-origin frame made after the page, a change glides at once, on that frame's own clock": with the page's clock and one shared start it fails 3 of 3, the row holding its old place for about half a second; with this change it passes 5 of 5 in Chromium and in WebKit.
  • The changeset and the comment in safeAnimate now say the animations start at the moment of the change.

@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from 90ba1b1 to c6887ab Compare November 1, 2026 10:58
@vjeux

vjeux commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in c6887ab:

  • A change made after a block that follows an earlier layout motion in the same task now starts after the block. Animations made together, each within LATE_START_MS of the one before, share one start however long making them takes, and a block since the last one gives the next change a start of its own. New browser case, "a change made after a block that follows an earlier layout motion in the same task still shows its motion": on the previous head the second change started on the frame time from before the block, 3 of 3 in Chromium and in WebKit; it passes here in both. A unit case guards that one swap's parts, made over 75 ms with no block between them, still share one start. The changeset and description describe the rule this way.
  • reportLayoutEdge's measureBefore clamps the running reveal's time at 0, like the other readers.

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

Requesting changes: a layout change made after a long task now plays instead of skipping (the new browser cases fail on main and pass here), and the two items from the last round are fixed. One regression remains: startFor groups animations by the gap between them, so a change's entrance (played in the adopter's layout effect) and its followers' glide (made after the commit) take different starts whenever the rest of the commit runs longer than 34 ms, and the revealed edge runs ahead of the row after it, up to 47 px with 60 ms of work in Chromium, where main keeps one start. Please tie the shared start to the change rather than to the gap between animations, and add a browser case with more than 34 ms of work between playLayoutChange and the flush.

[Automated review]

if (
start != null &&
start.frame === frame &&
now - start.last <= LATE_START_MS

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.

Grouping by the gap between two animations splits one change: an adopter plays the entrance in its layout effect (Collapsible.tsx:425-430) and the batch makes the followers' glide in a microtask after the whole commit, so any commit work over 34 ms in between gives the glide a fresh start. In Chromium, 60 ms of work after playLayoutChange put the entrance at 30.6 ms and the glide at 96.2 ms, and the revealed edge ran up to 47 px ahead of the row after it (main: one start, 0 px). Tying the start to the change (for example, deciding it when animate() queues the area's batch and handing it to that change's entrance, exit or edge) would keep both block cases working.

github-actions Bot added a commit that referenced this pull request Nov 1, 2026
@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from c6887ab to c2b0cbb Compare November 1, 2026 14:05
@vjeux

vjeux commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in c2b0cbb: the shared start is now tied to the change rather than to the gap between animations.

  • A change keeps one start from its first animation through the flush of its glides and the parts that ride them, however long the work between them runs: the start holds through the task that made it, while the timeline reads the same frame. A change that begins (its "before" is read) after a block since the last layout motion still takes a start of its own.
  • New browser case, "a change's own entrance and the glide of the content after it share one start, however long the rest of its commit runs", with 60 ms of work between playLayoutChange and the flush: on the previous head the two started about 65 ms apart, 3 of 3 in Chromium and in WebKit; they share one start here.
  • Two guards: "a change begun after a block that follows an earlier layout motion, with nothing run between them, still shows its motion", and "a swap whose parts ride the glide starts them with the glide, on the start read for the change, however late in its frame the change is made". The swap guard covers parts played a microtask after the glide flush, as the shell's rail swap is.

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

Requesting changes: a layout change made after a long task now plays instead of skipping, the new browser cases pass in Chromium and WebKit, and last round's entrance/glide split under 60 ms of commit work is fixed. One regression remains: the shared start lives in one slot per document, so when a second change begins after a block before the first change's glide flush has run (the case at animatedLayout.interaction.browser.spec.ts:803, with nothing run between them), beginChange replaces it and the first change's glide starts about 1 s after its own entrance, leaving its rows over the revealed content for the whole glide. Please capture the start for each change and hand it to that change's flush and riding parts, and assert in that case that the first change's glide starts with its entrance.

[Automated review]

Comment on lines +327 to +330
const held = changeStarts.get(doc);
if (held != null && clockOf(doc) - held.last > LATE_START_MS) {
changeStarts.delete(doc);
}

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.

When a second change begins here after a block, before the first change's glide flush (queued at line 1257) has run, the slot is emptied and the second change refills it, so the first change's glide takes the second change's start while its entrance keeps the earlier one. With the fixture of the case at animatedLayout.interaction.browser.spec.ts:803, the first change's entrance starts at about 25 ms and its glide at about 1,040 ms (Chromium 3 of 3; WebKit 28 vs 1,039 ms), and two frames after the block its rows cover the 120 px of revealed content. Capturing the start for the change (when animate() schedules the area's flush, or at its first animation) and handing it to that flush and the parts riding its glide would keep both block cases working.

@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from c2b0cbb to 8ba5b7d Compare November 1, 2026 16:12
@vjeux

vjeux commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in 8ba5b7d, rebased onto current main:

  • Each change now keeps its own start: a change's glide batch keeps the start its first animation took (its entrance, or its glides at the flush) through its flush, and the parts it plays later in the task capture it when played. A second change that begins after a block, before the first one's glides flush, takes a fresh start for itself only.
  • The case at animatedLayout.interaction.browser.spec.ts:803 now also requires the first change's glide to start with its entrance: on the previous head it started about 1 s later (3 of 3 in Chromium and in WebKit); it shares the entrance's start here.
  • The held FR9 inline-end reversal that went red in this PR's CI does not reproduce under the CI WebKit job's command, 80 of 80 with this head, the previous head's module and main's; the rebase lets the next run tell them apart.

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 1, 2026
@github-actions
github-actions Bot requested a review from cvkxx November 1, 2026 16:12

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

Recommending approval: a layout change made late in a long task now plays instead of finishing before the first frame, and last round's two-state reversal gap is fixed. The side navigation rail's edge now stays on the content when a reversal follows a block, and the new browser case catches the old 104.3 px gap; the block cases fail on main and pass here in Chromium and WebKit, and under Reduce Motion the rail's cross-fade now plays after a long tap.

  • Optional: the animatedLayout.ts file header this pull request edits runs about 78 lines; keeping @output to the export list would match the comment guideline.

[Automated review]

* `spec:AST-105` defines (`architecture:react-component-runtime` INV12)
* internal `springs.settle` motion role (motion/roles.ts), the Reduce Motion
* cross-fade clock (uikit/timing.ts) and the block measure (frameBlock.ts)
* @output Exports `createAnimatedLayout`, the opaque `AnimatedLayout` handle,

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.

Non-blocking: this header now runs from line 3 to line 81, and the comment guideline keeps @input, @output and @position to about 12 lines. Keeping @output to the export list, and moving the "How it works" list to the motion README, would fit it.

@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from d88b8aa to 3ff634d Compare November 3, 2026 16:11
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 3ff634d

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 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.

Requesting changes. The late-start fix works: the three block cases fail on main and pass here, the module and rail browser specs pass in Chromium, and the new component:SideNav FR6 sentence on the initial state has an engineering owner's approval for this head. Three things need fixing before it can merge:

  • frameTimeOf sits between SideNav's JSDoc block and export function SideNav (SideNav.tsx:459-466), so the exported component loses its documentation and @example in editors and the emitted types; move the helper above that JSDoc block.
  • The new useLayoutEffect at SideNav.tsx:555-557 only records the timeline's frame when the nav attaches; record it from a callback added to the nav's existing merged ref (SideNav.tsx:508) and remove the Effect.
  • In the rail's mount frame the head lands AppShell's content area too, but component:AppShell FR17 still says the content swaps on every collapse or expand; add the same initial-state sentence to FR17 in this pull request.

Non-blocking: the comment at SideNav.tsx:532 still says every collapse or expand plays the rail's motion.

[Automated review]

Comment thread packages/core/src/SideNav/SideNav.tsx Outdated
* ```
*/

/** The frame time a document's timeline reads, or null without one. */

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.

This helper now sits between SideNav's JSDoc block (lines 441-458) and export function SideNav, so TypeScript attaches that block to nothing and the exported component loses its description and @example in editors and in the emitted declaration. Move frameTimeOf above the JSDoc block.

Comment thread packages/core/src/SideNav/SideNav.tsx Outdated
Comment on lines +555 to +557
useLayoutEffect(() => {
mountFrameRef.current = frameTimeOf(navRef.current?.ownerDocument);
}, []);

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.

This Effect only records the timeline's frame when the nav element attaches. A callback added to the existing merged nav ref (useMergedRefs(ref, navRef, modalityRef), line 508) can record it at attachment, which also follows a replaced nav node; then this Effect can go.

@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from 3ff634d to 432cb9d Compare November 3, 2026 17:23
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 432cb9d

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

Requesting changes. The late-start fix works: after a slow click the side navigation rail's collapse, and its Reduce Motion cross-fade, now play instead of skipping, the module's browser spec passes in Chromium, its block and two-state cases pass in WebKit, and last round's three items are fixed. One thing needs fixing before it can merge:

  • recordMountFrame (SideNav.tsx:514-518) records the frame on every attach of the merged nav ref, and an inline callback ref on SideNav re-attaches it on every re-render, so a collapse the app makes in a later commit of that frame, after the rail has painted, lands with no motion (0 animations against 9 on main); record the frame only when the attached node changes, and add an inline-ref case to SideNavRailMotion.test.tsx.

Non-blocking: the animatedLayout.ts file header still runs about 78 lines, and the JSDoc on frameTimeOf restates its name and return type.

[Automated review]

Comment on lines +514 to +518
const recordMountFrame = useCallback((nav: HTMLElement | null) => {
if (nav != null) {
mountFrameRef.current = frameTimeOf(nav.ownerDocument);
}
}, []);

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.

This runs on every attach of the merged ref, and useMergedRefs makes a new merged callback whenever ref changes identity. With an inline ref={node => …} on SideNav, each re-render re-attaches the nav and records the current frame, so an app collapse in a later commit of the same frame (after the rail has painted) matches the check at line 577 and lands with no motion: 0 animations in a probe, against 9 on main and 9 with a stable ref. Recording only when the attached node differs from the last one recorded keeps the initial-state cases passing and plays the change.

vjeux added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from 432cb9d to a3b1fb7 Compare November 3, 2026 20:02
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec a3b1fb7

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

Requesting changes. The late start fixes the skipped rail collapse and the skipped Reduce Motion cross-fade after a slow tap, and the inline-ref guard keeps later changes animated. One reversal path still mixes two clocks.

Blocking

  • A rail toggle that reverses a running collapse after a long task restarts the content area's cross-fade and the rail copy's fade from their pre-block progress while the glide carries on from where the compositor has it (AppShell.tsx:1000-1004, animatedLayout.ts:2614), so read that progress at the change's start as flush does with change.at (in AppShell, layoutStartFor(main.ownerDocument) - last.startedAt) and add a browser case for a second toggle after a block.

Non-blocking

  • The component:AppShell FR17 verification row credits SideNavRailMotion.interaction.browser.spec.ts with the before-first-paint case, which only the unit test covers.

[Automated review]

Comment on lines +1000 to +1004
const elapsed = Math.max(
0,
Number(main.ownerDocument.timeline?.currentTime ?? 0) -
last.startedAt;
last.startedAt,
);

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.

This progress is read on the timeline's held frame, but the glide this change retargets carries on from the compositor's time at the change's start (animatedLayout.ts:1212-1216). After a block the two disagree: a collapse, then an expand 150 ms later behind 1 s of click-handler work, starts the collapsed text's copy at 0.73 and the expanded text at 0.27, although the collapse had ended by then (a settled reversal starts at 0.93 and 0.07). Reading layoutStartFor(main.ownerDocument) - last.startedAt here gives 0.96 and 0.04 for the same reversal and leaves a reversal without a block unchanged (0.71 and 0.29).

motion.kind === 'spring' ? motion.progress.durationMs : motion.durationMs;
const shown = (): {extent: number; progress: number} | null => {
const elapsed = now() - startedAt;
const elapsed = Math.max(0, now() - startedAt);

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.

The rail's fades take their progress from this shown(), read on the timeline's held frame. In the same reversal after a block, the rail's held copy starts at 0.18 where a settled reversal starts at 0.89, so the rail's icons flash back while its edge rides on. Reading the progress at the change's start, as the glide does, keeps the reversal from the shown state (spec:AST-105 FR9).

* `playLayoutEdge`), `playLayoutFrames` and `applyLayoutChangeTransition`:
* the one module that produces the size-change glide and the edge reveal
* `spec:AST-105` defines (`architecture:react-component-runtime` INV12)
* internal `springs.settle` motion role (motion/roles.ts), the Reduce Motion

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.

Non-blocking (INV29): this header still runs from line 3 to line 81, against about 12 lines. Keep @output to the export list and move the "How it works" list to the motion README.

…instead of skipping past it

The layout module started every animation of a change on the document
timeline's current time, so a retargeted glide keeps moving through the
frame it is replaced in and a change's animations share one start.
Chromium holds that time at the frame before a long task once anything
in the task reads it, so a change made late in such a task started in
the past: the first frame after the block showed it skipped into its
curve, or past all of it. After a 1 s tap task on a slow device, the
side navigation rail's Reduce Motion cross-fade never showed.

The module now starts a change on the timeline time only while that
frame is at most LATE_START_MS old. Otherwise its animations start
together at the moment the change makes its first one, and hold their
first keyframe until the timeline gets there, so the block delays the
motion instead of skipping it. A change keeps one start from its first
animation (the changed element's own entrance, say) through the flush of
its glides and the parts that ride them, played in the microtasks after
it, however long the rest of the commit runs: the start holds through
the task that made it. A change that begins (its "before" read) after a
block since the last layout motion takes a fresh start, so a change made
after a block that follows an earlier layout motion in the same task
plays too. Each change keeps the start it took, in its glide batch and
in the parts it plays later in the task, even when another change begins
after a block before its glides flush; a change that begins in the same
area before those glides flush joins that change and its start. A glide
such a change retargets carries on from where the compositor has it at
the change's start, rather than from the frame the timeline held through
the block. The parts that ride such a glide, as the side navigation
rail's two-state edge does, ride it from where it showed when they were
read, so they move with the content instead of parting from it by the
block's drift. The edge reveal's own progress (the rail's width) and
AppShell's swap follow a change on the start the module gives it
(layoutStartFor) instead of the timeline time at the change. Each
document keeps its own start, on its own clock, so a change in an iframe
is not dated by the page's. The animator's block measure moves to
motion/frameBlock.ts, which both read.

The side navigation's initial state never animates: a collapse or expand
made before the rail first paints, other than by the rail's own toggle,
lands at once with the content. Until a frame runs after the rail
mounts, the document timeline reads the frame it read at the mount, so
the rail compares the two. The mount frame is read once per nav node,
so an inline ref that re-attaches the nav on each render does not
restart it. Before this change, a state an app restores during a long
load task would have glided once that task ended.

A riding edge's `shown()` now reads the ridden element where its glide
shows on the timeline's clock, from the glide's own curve. WebKit
evaluates a running translate on the live clock after a block, while
the timeline still reads the frame before it, so a reversal read late
in its task started the edge ahead of or behind the content. The two
reads now agree in every engine.


After a long task, a reversal's fades start from the progress at the
change's start, where the glide it retargets carries on: the content
area's cross-fade in AppShell and the rail copy's fades through the
edge's `shown()`. The riding edge's extent stays on the timeline's
frame, the frame its ride is measured from.
@vjeux
vjeux force-pushed the uikit/f1-layout-start-after-block branch from a3b1fb7 to 5ce160e Compare November 3, 2026 21:21
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 2026
@cixzhang

cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 5ce160e

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 3, 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.

Recommending approval: after a slow tap, the side navigation rail's collapse and its Reduce Motion cross-fade now play instead of finishing before the first frame, and a reversal after a long task starts its fades from what the page shows.

  • A reversal after a long task now starts the content area's cross-fade and the rail's fades from the change's start, and the new browser case fails without that fix.
  • The new initial-state requirement in component:SideNav FR6 and component:AppShell FR17 has an engineering owner's approval on this head.
  • Non-blocking: the animatedLayout.ts file header still runs about 79 lines; trimming @output to the export list would bring it near the comment guideline.

[Automated review]

* `spec:AST-105` defines (`architecture:react-component-runtime` INV12)
* internal `springs.settle` motion role (motion/roles.ts), the Reduce Motion
* cross-fade clock (uikit/timing.ts) and the block measure (frameBlock.ts)
* @output Exports `createAnimatedLayout`, the opaque `AnimatedLayout` handle,

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.

Non-blocking: this file header still runs from line 3 to line 81, against the comment guideline's "about 12 lines". Keep @output to the export list and move the "How it works" list to the motion README.

@vjeux
vjeux marked this pull request as ready for review November 3, 2026 22:14
github-actions Bot added a commit that referenced this pull request Nov 3, 2026
@cixzhang
cixzhang marked this pull request as draft November 3, 2026 23:47
@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 23:47
github-actions Bot added a commit that referenced this pull request Nov 4, 2026
@cixzhang
cixzhang merged commit 73996f1 into meta:main Nov 4, 2026
161 of 162 checks passed
@vjeux
vjeux deleted the uikit/f1-layout-start-after-block branch November 4, 2026 01:02

This branch was successfully deployed

1 active deployment
Preview — 5ce160e9 Deployed Nov 3, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants