Skip to content

perf(panel): an empty toast stack measures nothing on every draw - #4324

Merged
luke-agent[bot] merged 1 commit into
mainfrom
luke/toast-glide-idle
Oct 21, 2026
Merged

luke-agent[bot] merged 1 commit into
mainfrom
luke/toast-glide-idle

Conversation

@charleslpan

@charleslpan charleslpan commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

This is a follow-up to #4296, found by the profile Charles asked for after it merged.

The problem: useStackGlide in toast.tsx runs a useLayoutEffect with no dependency list. After every draw of the toast stack it reads --duration-fast and --spring-fast through getComputedStyle, plus every toast's box. Each read forces a style or layout pass over the whole window, and it happens even though the stack is nearly always empty.

The evidence: a 15 s profile of the panel at rest on bae007ad2, which includes #4296, put 203 ms in getPropertyValue from toast.tsx:401. That is about a fifth of the main thread's busy time in that window, and the cost grows with the size of the DOM.

The fix: an empty stack now returns before reading anything. A stack with toasts in it glides as before.

The behavior doesn't change. The existing toast tests pass, and I added none, since all that changes is the work done.

I swept packages/panel and packages/ui for other useLayoutEffect calls with no dependency list that read layout. The rest already return early when they have nothing to do: plan comments with no threads, a reveal that isn't pending, a combobox with no active row.

Made with Luke


Devin Review

View guided diff Turn on auto-fix

The toast stack's glide ran a layout effect after every draw, with no
dependency list. It read the motion tokens through getComputedStyle and
every toast's box, which lays out the whole window, even though the stack
is empty nearly always. A profile of the panel at rest put it at about a
fifth of the main thread's busy time. An empty stack now returns before
reading anything.

Co-authored-by: luke-agent[bot] <339870089+luke-agent[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
luke-web Ready Ready Preview Oct 21, 2026 1:35am UTC

Request Review

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@luke-agent
luke-agent Bot added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 06498de Oct 21, 2026
12 checks passed
@luke-agent
luke-agent Bot deleted the luke/toast-glide-idle branch October 21, 2026 14:43

This branch was successfully deployed

1 active deployment
Preview — 79c9337e Deployed Oct 21, 2026 by vercel[bot]
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.

1 participant