Skip to content

perf: run the spectrum-slide animation only while the gradient is visible - #8296

Open
ankur-arch wants to merge 1 commit into
mainfrom
perf/spectrum-slide-idle-cpu
Open

ankur-arch wants to merge 1 commit into
mainfrom
perf/spectrum-slide-idle-cpu

Conversation

@ankur-arch

@ankur-arch ankur-arch commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #8209.

spectrum-slide animates background-position, which the browser cannot composite, so every element carrying it repaints on every frame. The ring, ink, ink-text and underline rules attached the animation to the resting state and hid it with opacity: 0, which hides the pixels but not the work. The docs sidebar ran it on every row and the homepage on every ghost, link and outline button.

The animation now starts on the same selector that reveals the gradient (hover, focus-visible, data-active, or the -on variant), and the reduced-motion blocks cover those selectors too. While a gradient is shown it looks the same as before; at rest nothing animates.

Same change in apps/site/src/app/globals.css and packages/eclipse/src/styles/globals.css (the copy the docs and blog use).

Validation

Reproduced in Chrome with document.getAnimations() before the change:

Page spectrum-slide animations running at idle
prisma.io homepage 58
/docs/orm/v7/reference/prisma-client-reference 45 (one per sidebar row)

After the change (local dev servers): the docs page runs 1 (the selected sidebar row) and the homepage runs 1 (the spectrum-border-on element). Hover and focus still start the slide.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Style

    • Spectrum border, ink, underline, text, and ring animations now activate when their visual effects are visible, including hover and keyboard focus states.
    • Always-on border animations continue running continuously.
    • Sidebar and tile ring animations now follow the same visibility-based behavior.
  • Accessibility

    • Reduced-motion preferences now apply consistently to hover, focus, selected, and ring-hover animation states.

…ible

`spectrum-slide` animates `background-position`, which the browser cannot
composite, so every element carrying it repaints on every frame. The ring,
ink, ink-text and underline rules attached the animation to the resting
state and hid it with `opacity: 0`, which stops the pixels but not the
work. On the docs sidebar every row (40+ on an ORM page) ran it at once,
and the homepage ran it on 37 buttons and links, which is the sustained
idle CPU reported in #8209.

The animation now starts on the same selector that reveals the gradient
(hover, focus-visible, `data-active`, or the `-on` variant) and the
reduced-motion blocks cover those selectors too, so the visual is the
same while shown and nothing animates at rest.

Closes #8209

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
blog Ready Ready Preview Sep 17, 2026 2:53pm UTC
docs Ready Ready Preview Sep 17, 2026 2:53pm UTC
eclipse Ready Ready Preview Sep 17, 2026 2:53pm UTC
site Ready Ready Preview Sep 17, 2026 2:53pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Essentials

Run ID: b0137438-f071-4e8c-a53b-7b90f9a668ef

📥 Commits

Reviewing files that changed from the base of the PR and between d5027b7 and eaeaf9a.

📒 Files selected for processing (2)
  • apps/site/src/app/globals.css
  • packages/eclipse/src/styles/globals.css

Included review availability: 2 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


Walkthrough

Spectrum animations in both style sheets now run only for visible hover, focus-visible, selected, or always-on states. Reduced-motion rules cover the added selectors, including sidebar and tile rings.

Changes

Spectrum animation gating

Layer / File(s) Summary
Site spectrum interaction states
apps/site/src/app/globals.css
Border, ink, text, and underline animations now use visible interaction states. Reduced-motion rules cover hover and focus-visible states.
Eclipse spectrum interaction states
packages/eclipse/src/styles/globals.css
Border, ink, text, and underline animations now use visible interaction states.
Eclipse ring interaction states
packages/eclipse/src/styles/globals.css
Sidebar and tile ring animations now activate for selected or hovered states. Reduced-motion rules cover these states.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix · Severity of issue fixed: High

Suggested reviewers: amanvarshney01

Merge Risk: ⚪ Minimal · up to eaeaf

The animation gating preserves visible interaction states and reduced-motion coverage while removing idle repaint work. No merge-blocking issue is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: limiting the spectrum-slide animation to periods when the gradient is visible to reduce unnecessary repaint work.
Linked Issues check ✅ Passed For #8209, the PR gates spectrum-slide animations on visible states such as hover, focus-visible, data-active, and -on variants. It updates sidebar, ink, text, underline, border, ring-hover, a…
Out of Scope Changes check ✅ Passed The changes are limited to animation and reduced-motion rules in apps/site/src/app/globals.css and packages/eclipse/src/styles/globals.css. The selectors directly support #8209 by preventing hidde…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High CPU comsumption caused by spectrum-slide animation

1 participant