Fix pixel spinner stuck paused when created detached#324028
Draft
benibenj wants to merge 1 commit into
Draft
Conversation
The pixel spinner starts paused and relies on a per-window IntersectionObserver to unpause it once on screen. Spinners are created detached and appended shortly after, so the observer's initial callback can fire while the element is still disconnected. The old cleanup then unobserved it permanently, leaving it stuck with the paused class. Only unobserve elements that were connected at least once (genuine removals), so not-yet-inserted spinners keep being observed and unpause when appended. Fixes #324018 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes a race condition in the shared createPixelSpinner implementation that could leave spinners permanently paused when they’re created/observed while detached from the DOM (common with virtualized rendering) and only appended shortly afterward.
Changes:
- Add
everConnectedtracking to distinguish “not yet inserted” spinners from spinners that were removed after being connected. - Only
unobserve()detached spinners that have previously been connected, preventing premature cleanup that caused the paused class to stick.
Show a summary per file
| File | Description |
|---|---|
| src/vs/base/browser/ui/pixelSpinner/pixelSpinner.ts | Keeps observing detached-but-never-connected spinners so they unpause after insertion, while still unobserving removed spinners to avoid retaining detached elements. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Low
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #324018
Problem
The in-progress pixel spinner in the sessions list sometimes never animates and stays stuck with the
monaco-pixel-spinner-pausedclass — reproducibly when creating a new session.Root cause
The pixel spinner is created paused and relies on a per-window
IntersectionObserverto unpause it once it is on screen. HoweverSessionStatusIconcreates the spinner detached (createPixelSpinner(undefined, …)) and appends it to the DOM a moment later.An
IntersectionObserveralways delivers an initial callback for every observed target. If that callback arrives while the element is still detached, the old code hit the!target.isConnectedbranch and calledobserver.unobserve(target)permanently. Once the spinner was inserted into the list it was no longer being observed, so it never got the class removed. When the append happened to win the race (e.g. re-renders of existing sessions), it worked — hence "works sometimes".Fix
The
unobservecleanup exists to avoid leaking references to spinners that get removed from the DOM (e.g. the outgoing icons during a cross-fade swap). AWeakSet(everConnected) now lets the observer distinguish the two cases: