Repository navigation
fix(CircularProgress): a value change keeps moving while JavaScript runs - #8232
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsCircularProgress (@astryxdesign/lab) · View in Storybook
Component Size
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 SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
There was a problem hiding this comment.
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
isIndeterminateturns on mid-change, the early return atCircularProgress.tsx:579still runs before the running animations are cancelled, so they keep running on the removed layers and stay inmotion.current(architecture:react-component-runtimeINV3 and INV5); please cancel them and clearmotion.currentthere or in a cleanup, and add a test that switches to indeterminate mid-change. - The new
pr-a11ystep has no scope check, so it runs on every pull request that changes a component (49 s on this run), whilespec:AST-030FR12 keeps PR a11y to changed components plus fast interaction guards; please give it thepr-scope-touches.shguard the Progressbar step already uses forpackages/lab/src/CircularProgress/, or add the spec to that step. architecture:component-style-authoringINV6 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]
| # 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
| // 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. |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]
|
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 The reduced-motion question is in the comment below, for the engineering owners. |
|
This pull request can't be approved until an engineering owner decides one case: a Lab CircularProgress's value change under Reduce Motion. Should the change land at once on every pointer, as this branch does? Or should it follow 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. |
There was a problem hiding this comment.
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]
| transitionDuration: { | ||
| default: durationVars['--duration-medium'], | ||
| '@media (prefers-reduced-motion: reduce) and (not (pointer: coarse))': | ||
| '0s', | ||
| '@media (prefers-reduced-motion: reduce) and (pointer: coarse)': '0s', | ||
| }, |
There was a problem hiding this comment.
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.
| // Progress indicators sit outside design:reduced-motion's scope; the | ||
| // fill lands at once under both shared reduced-motion queries. |
There was a problem hiding this comment.
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.
|
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]>
b12bd8b to
25701d9
Compare
There was a problem hiding this comment.
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]
…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).
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:
strokestill colors every part, butstroke-widthandstroke-linecapno longer reach the drawing.Only the third keeps moving.
Expected behavior and authority
Apple: "Keep progress indicators moving." No CircularProgress record. The
circular-progress-filltarget moves to the fill's wrapper. Under Reduce Motion a change still sweeps over the theme's duration, as onmain: Lab sits outsidedesign: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
Scope
Testing
What I ran and what it showed:
mainholds one position, then jumps; this PR shows 14 positions, always one piece.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.