Skip to content

fix(CircularProgress): a value change keeps moving while JavaScript runs - #8232

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c07-circular-compositor
Oct 31, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:uikit/c07-circular-compositor

Conversation

@vjeux

@vjeux vjeux commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Part of making Astryx match iOS, whose progress indicators keep moving while busy. A CircularProgress given a new value on a busy page, as progress usually arrives, freezes, then jumps (Chromium, Safari), so the transfer looks stalled. Now it keeps moving, with the same timing, colors and geometry.

Problem and solution fit

What led to it: the arc animates stroke-dashoffset, repainted on the main thread every frame.

Options:

  • Keep the dash animation: the ring freezes.
  • Animate a conic mask's angle: repainted every frame, like the dash.
  • Layers the compositor turns (this PR): two clipped half-rings and two round caps, moved by Web Animations on the theme's timing. Costs: 16 elements instead of 3 (INV7); stroke still colors every part, but stroke-width and stroke-linecap no longer reach the drawing.

Only the third keeps moving.

Expected behavior and authority

Apple: "Keep progress indicators moving." No CircularProgress record. The circular-progress-fill target moves to the fill's wrapper. Under Reduce Motion a change still sweeps over the theme's duration, as on main: Lab sits outside design:reduced-motion's scope, so that stays as it is until the owner decides.

Smallest restoration

CircularProgress.tsx, the determinate fill only; everything else, API included, is unchanged. A change releases its animations when it ends or unmounts.

Evidence

  • iOS simulator, 10% → 90% during a 0.7 s busy script; main left, this PR right:
    The ring frozen on main and moving with this PR through the block
  • A change arriving mid-way turns back from where the arc is:
    A change to 40% arriving while 10% → 90% runs
  • At rest, the stroked circle (top) and the layers:
    Stroked circle and ring at rest
  • 20% → 80%, frame by frame:
    Ring moving frame by frame

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

What I ran and what it showed:

  1. The large ring on the iOS 26.2 simulator, 10 → 90 through a 0.7 s busy script: main holds one position, then jumps; this PR shows 14 positions, always one piece.
  2. Chromium tests: no layout or paint while it moves, the same drawing as the stroked circle at ten values, one piece across 6 o'clock, the theme's duration and easing, under Reduce Motion too.
  3. Tests for a lighter band at 6 o'clock when a shrinking change arrived mid-way; both failed before its fix.
  4. Local gates at 25701d9: root build, typecheck, ESLint, Prettier, Storybook, the CircularProgress Chromium tests (16) and pnpm test:ui (16,463) pass; the node project fails only test(storybook): run the story-tree check where Storybook is built, and bring the tree back to its shape #8509's and fix(cli): a crashed run's release install is recognized by the Node it ran on, whatever its name #8520's known cases.

@vercel

vercel Bot commented Oct 24, 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 Oct 30, 2026 11:26pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 30, 2026, 11:36 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

CircularProgress (@astryxdesign/lab) · View in Storybook
Metric Before After Delta
Entry File (ESM) 185B 185B 0B
Lines of Code 328 597 -
Complexity High Very High (57) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
lab/CircularProgress 7.1KB 8.4KB +1.3KB 1.0KB 1.1KB +108B

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/lab 4.6KB 1.9KB 1.9KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/lab 11.2KB 11.3KB +79B

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

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

Changes requested: the compositor-driven ring keeps moving through main-thread work and matches the stroked circle at rest, but an update that arrives while a change is still running restarts the arc behind where it is drawn. In CircularProgress.tsx the restart point multiplies by the running animation's linear getComputedTiming().progress while the keyframes follow the theme's eased curve, and the stored FillMotion.ease is never applied, so in Chromium an update 100 ms into a 10% → 90% change jumps the arc back about 147° and streamed progress stutters backward. Please start the new change at running.from + (running.to - running.from) * running.ease(progress), add a test that interrupts a change under a non-linear easing, and cancel the running animations when isIndeterminate turns on mid-change. Rebasing on main will also let the pr-a11y job reach the new browser step, which was skipped on this run.

[Automated review]

first != null && first.playState !== 'finished'
? Number(timing?.progress ?? 1)
: 1;
from = running.from + (running.to - running.from) * progress;

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.

progress here is getComputedTiming().progress of an animation whose timing easing is linear, so it is the elapsed fraction. The keyframes, though, put the arc at from + (to - from) * ease(t). With --ease-standard the arc is drawn far ahead of that fraction, so an update during a running change restarts it behind where it is drawn: in Chromium, 100 ms into 10% → 90% the arc is at 77.6%, but the update to 95% starts at 36.7%. FillMotion.ease is stored for exactly this and never read:

from = running.from + (running.to - running.from) * running.ease(progress);

const previous = shown.current;
shown.current = percentage;
const running = motion.current;
if (previous === percentage || isIndeterminate) {

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 isIndeterminate turns on during a change, this early return leaves the four running animations on the layers that are about to unmount, and keeps them in motion.current. architecture:react-component-runtime INV3 asks the effect's cleanup to release what its setup starts; cancelling and clearing here (or in a cleanup) closes the gap.

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

Changes requested: the compositor-driven ring keeps moving through main-thread script with the stroked circle's timing and resting pixels, and the interrupted-change restart from the earlier revision is fixed and tested. One lifecycle gap remains: when isIndeterminate turns on during a change, the early return at CircularProgress.tsx:568 runs before the running animations are cancelled, so they keep running on the removed layers and a quick return to determinate can start from that stale change, which architecture:react-component-runtime INV3 and INV5 rule out. Please cancel the animations and clear motion.current in that branch, or release them in the effect's cleanup after recording the drawn position, and add a test that switches to indeterminate mid-change.

[Automated review]

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

Changes requested: the compositor ring keeps moving through main-thread script with the theme's timing and the stroked circle's resting drawing, and the 6 o'clock fix in the latest commit is covered by unit and Chromium tests. Three things remain:

  • When isIndeterminate turns on mid-change, the early return at CircularProgress.tsx:579 still runs before the running animations are cancelled, so they keep running on the removed layers and stay in motion.current (architecture:react-component-runtime INV3 and INV5); please cancel them and clear motion.current there or in a cleanup, and add a test that switches to indeterminate mid-change.
  • The new pr-a11y step has no scope check, so it runs on every pull request that changes a component (49 s on this run), while spec:AST-030 FR12 keeps PR a11y to changed components plus fast interaction guards; please give it the pr-scope-touches.sh guard the Progressbar step already uses for packages/lab/src/CircularProgress/, or add the spec to that step.
  • architecture:component-style-authoring INV6 asks every component change to report the base-against-head gzip JavaScript and CSS size, so please add CircularProgress's figures to the description.

[Automated review]

Comment thread .github/workflows/ci.yml Outdated
# nothing per frame, and at rest it draws what the stroked circle drew.
# jsdom has no compositor, paint or pixels, so only a real engine shows
# it.
- name: Run CircularProgress busy main thread contract

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 step has no scope check, so it runs on every pull request that changes any component (8 tests in 49.1 s on this run, more than twice the slowest unscoped guard in the job). spec:AST-030 FR12 keeps PR a11y to changed components plus fast interaction guards. The Progressbar step above already routes on packages/lab/src/CircularProgress/; giving this step the same pr-scope-touches.sh guard and if: ${{ !cancelled() && github.event_name == 'pull_request' }}, or adding the spec to that step, keeps it to CircularProgress changes.

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

Approval waits on one engineering-owner decision: the compositor ring keeps moving through main-thread script with the theme's timing and the stroked circle's resting drawing, and the earlier requests (cancelling a running change on indeterminate, scoping the pr-a11y step, the size report) are addressed. The latest commit also makes a new value appear at once under prefers-reduced-motion: reduce, which no current spec covers for a Lab component (design:reduced-motion applies only to packages/core/src/**), so an engineering owner needs to identify or extend the spec that governs it, or decline it, and records an approval by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. Whichever way it is decided, please correct the comment at CircularProgress.tsx:212-213: ProgressBar's fill still animates under reduced motion, so it is not a precedent.

[Automated review]

Comment on lines +212 to +213
// so nothing transitions on its own). Under reduced motion the duration is
// 0 s, so a new value shows at once, as ProgressBar's fill does.

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.

ProgressBar's fill has no reduced-motion override (packages/core/src/ProgressBar/ProgressBar.tsx, fill keeps transitionDuration: durationVars['--duration-medium']), and under prefers-reduced-motion: reduce it still runs a 300 ms width transition in Storybook, so it is not a precedent for this branch. Whichever way the reduced-motion question is decided, this comment needs updating.

transitionProperty: 'none',
transitionDuration: {
default: durationVars['--duration-medium'],
'@media (prefers-reduced-motion: reduce)': '0s',

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 makes a new value appear at once under reduced motion, where main sweeps it over --duration-medium. design:reduced-motion applies only to packages/core/src/**, so this behavior for a Lab component needs an engineering owner to identify or extend the governing spec before approval.

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

Approval waits on one engineering-owner decision: the compositor ring keeps moving through main-thread script with the theme's timing and the stroked circle's resting drawing, but showing a new value at once under prefers-reduced-motion: reduce is behavior no current spec covers for a Lab component (design:reduced-motion applies only to packages/core/src/**). An engineering owner needs to identify or extend the spec that governs reduced motion for Lab progress indicators, or decline it so the branch and its tests come out, and records that decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. Whichever way it is decided, please correct the comment at CircularProgress.tsx:212-213: ProgressBar's fill still animates under reduced motion, so it is not a precedent.

[Automated review]

vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 26, 2026
@vjeux

vjeux commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

Corrected in 9774bbb. The reduced-motion comment no longer cites ProgressBar's fill, which on main still animates under reduced motion. It gives the real reason instead: a Lab component sits outside design:reduced-motion's scope, which covers core. The same commit points the accessibility binding's ring-geometry exclusion at the size and half-ring turn tests that replaced the dash-offset test.

The reduced-motion question is in the comment below, for the engineering owners.

@vjeux

vjeux commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

This pull request can't be approved until an engineering owner decides one case: a Lab CircularProgress's value change under Reduce Motion. design:reduced-motion covers core (packages/core/src/**), so no current record governs it.

Should the change land at once on every pointer, as this branch does? Or should it follow design:reduced-motion as core would: an opacity-only cross-fade of 200 ms or less on a coarse pointer, at once otherwise? Or should it keep the theme's eased turn?

What this branch does: under both shared reduced-motion queries the half-rings' turn runs in 0 s, so the arc never travels. With motion allowed, a change keeps the theme's duration and easing, on the compositor. A cross-fade between two arc lengths would need the old arc drawn a second time.

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

Approval waits on one engineering-owner decision: the compositor ring keeps moving through main-thread script with the theme's timing and the stroked circle's resting drawing, but showing a new value at once under prefers-reduced-motion: reduce is behavior no current spec covers for a Lab component (design:reduced-motion applies only to packages/core/src/**). An engineering owner needs to identify or extend the spec that governs a Lab progress indicator's value change under reduced motion (at once on every pointer, a short cross-fade on touch as core does, or the eased turn), or decline the branch so the two 0s entries and their tests come out, and records that decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. Whichever way it is decided, please correct the comment at CircularProgressMotion.a11y.chromium.spec.ts:728-729: CircularProgress sits outside that record because it is a Lab component, while core's ProgressBar sits inside it.

[Automated review]

Comment on lines +225 to +230
transitionDuration: {
default: durationVars['--duration-medium'],
'@media (prefers-reduced-motion: reduce) and (not (pointer: coarse))':
'0s',
'@media (prefers-reduced-motion: reduce) and (pointer: coarse)': '0s',
},

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 makes a new value appear at once under prefers-reduced-motion: reduce, where main sweeps it over --duration-medium (300 ms in Storybook) with a mouse and with a finger. design:reduced-motion applies only to packages/core/src/**, so an engineering owner needs to decide this behavior for a Lab component and name or extend the governing record before approval.

Comment on lines +728 to +729
// Progress indicators sit outside design:reduced-motion's scope; the
// fill lands at once under both shared reduced-motion queries.

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.

design:reduced-motion applies to packages/core/src/**, which includes core's ProgressBar, so progress indicators as a class are not outside it. CircularProgress is outside because it is a Lab component, as the comment at CircularProgress.tsx:221-224 says; this comment should say the same, or cite the record an owner names.

@cixzhang cixzhang closed this Oct 28, 2026
@cixzhang cixzhang reopened this Oct 28, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

Posted by Cindy's agent on her behalf: closed and reopened only to restart this PR's CI on the current workflow after tonight's queue-wide cancel; nothing in the PR changed.

A determinate ring's value change ran as a stroke-dashoffset transition, which repaints on the main thread every frame, so it stopped while a script ran and then jumped to the new value. Two half-ring layers, each turned by transform and clipped to its half of the box, now draw the arc, with a round cap at each end, so the change runs on the compositor. The theme's duration and easing time it in every motion setting, as before.

Co-authored-by: Cindy Zhang <[email protected]>

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

This looks ready to approve: the compositor-driven ring keeps moving while a script holds the main thread, draws what the stroked circle drew at rest and mid-change, and the unit tests and Chromium specs pass on this revision. Before merge, please update the description: it still says a new value shows at once under Reduce Motion and lists "no animation under Reduce Motion" among the tests, but this revision keeps the theme's sweep in every motion setting and its spec asserts that. The size figures in the description also come from an earlier revision, so re-measure them once CI runs.

[Automated review]

cixzhang pushed a commit that referenced this pull request Oct 31, 2026
…s tooltip (#8569)

## Maintainer impact

Found when the Spinner and CircularProgress fixes (#8177, #8232) hit this race in CI. Since #8519, `CodeBlockHeaderPlugin.test.tsx` can fail on a busy CI runner with no rich-text change: a header's text read `['ts', 'js']` instead of `['tsCopy code', 'jsCopy code']` on pull requests that touch neither rich text nor layers, which then needed a re-run.

## Intended invariant

Each code block header shows its language label and a copy button whose tooltip reads "Copy code" (`spec:AST-061` FR8). The tests assert that text; product behavior stays as it is.

## Change

What led to it: a header's text ends with its copy button's tooltip. Since #8519 the tooltip's layer is placed by its own slot one render after the header (the slot gets its mount from a store subscription). Three tests waited for the header to exist, then read its text, so a late slot render left the tooltip out.

Options:

- Wait for the full text inside `waitFor` (this PR): the tests stop assuming one render.
- Render the tooltip in the header's render: a product change that would undo #8519's performance gain.
- Retry or skip the flaky tests: that hides the race.

This PR takes the first, since the one-render assumption was the tests', not the product's. The first test already finds the button by its accessible name, present from the start, so it is unchanged.

## Evidence

- Failure before the change: with the slot seeing its mount 30 ms late (a temporary edit in `useLayer.tsx`), the old tests fail as the failing runs did: `expected '' to be 'Copy code'`, and `['', 'Plaintext']` for `['Copy code', 'PlaintextCopy code']`.
- Success after the change: with the same delay the new tests pass, and without it too.
- Product/runtime behavior verified unchanged: only the test file changes.

## Scope

- [x] No intended public API, product behavior, visual direction, or policy change.
- [x] Product changes discovered during the work were removed or split.
- [x] Public text and artifacts contain no internal Meta context.

## Testing

What I ran and what it showed:

1. `pnpm exec vitest run --project ui packages/richtext/src/CodeBlockHeaderPlugin.test.tsx`: all four tests pass.
2. With the layer mount store's update in `useLayer.tsx` delayed 30 ms, its value and its listeners both (a temporary edit): main's file fails three of the four tests; this file passes all four.
3. Local gates at 7d01151: root build, typecheck, ESLint, Prettier, the duration guard and `pnpm test:ui` (16,446 tests) pass; in the node project, the only failures are `cache.test.mjs`'s two install-lock cases, a known failure on this machine (#8520).
@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 02:23
@cixzhang
cixzhang merged commit 4426e15 into meta:main Oct 31, 2026
100 checks passed
@vjeux
vjeux deleted the uikit/c07-circular-compositor branch October 31, 2026 02:57
cixzhang added a commit to vjeux/astryx that referenced this pull request Nov 3, 2026
meta#8232 merged as 4426e15, so this branch now carries only its own change.
Conflicts in CircularProgress.tsx, its test and the motion spec are
resolved by applying this branch's change since the merged meta#8232 head
(41941f5) onto main's meta#8232.

This branch was successfully deployed

1 active deployment
Preview — 25701d98 Deployed Oct 30, 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