Skip to content

Don't retain the faded out editor message widget - #337854

Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit into
mainfrom
agents/leak-message-controller-widget
Sep 25, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 1 commit into
mainfrom
agents/leak-message-controller-widget

Conversation

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Related to #146841

MessageController kept the last message widget in _messageWidget after it faded out, and the fade-out disposable kept referencing it too, so the widget and its DOM stayed alive until the next message was shown in that editor.

The widget is now handed over to the fade out (clearAndLeak), and the fade out keeps all references in a store that is emptied once the animation completes.

Measurement

Scenario Without this change With this change
Show an editor message (F12 where there's no definition → "No definition found"), let it close 4 detached DOM nodes (monaco-editor-overlaymessage) + the MessageWidget 0

Small and bounded (one widget per editor that showed a message); included for completeness of the #146841 cleanup since it shows up in every detached elements listing after using Go to Definition.

How this was measured

Code OSS (Electron, dev build) driven over CDP with Playwright. After each scenario: 4× forced GC, then DOM.getDetachedDomNodes (the data behind Edge's Detached Elements tool), counting the descendants of every detached root. "Without this change" means all other fixes from this series applied and only this one reverted, so the number shows what this retainer alone keeps alive. Each scenario was run 3 times with identical results. The retainer was identified from a heap snapshot retainer path.

MessageController kept the last message widget after it faded out until the next message was shown. Hand the widget over to the fade out and make sure the returned disposable doesn't reference it after it completes.

Related to #146841

Co-authored-by: Copilot <[email protected]>
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Sep 25, 2026
Copilot AI balanced review requested due to automatic review settings September 25, 2026 00:27
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues label Sep 25, 2026

Copilot AI 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.

Copilot review overview

🟢 Approval recommended

The revised ownership and disposal flow correctly releases widget and DOM references after fade-out.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes retention of faded editor message widgets by transferring widget ownership to a self-cleaning fade-out disposable.

Changes:

  • Releases MessageController ownership when fading starts.
  • Disposes widget, listener, and timeout after animation completion.
File Description
src/​vs/​editor/​contrib/​message/​browser/​messageController.ts Cleans up faded message widgets and associated references.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the editor-core Editor basic functionality label Sep 25, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added this to the 1.140.0 milestone Sep 25, 2026
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added editor-contrib Editor collection of extras and removed editor-core Editor basic functionality labels Sep 25, 2026
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) marked this pull request as ready for review September 25, 2026 01:36
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit ee77861 into main Sep 25, 2026
36 checks passed
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) deleted the agents/leak-message-controller-widget branch September 25, 2026 01:45
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 27, 2026
MessageController kept the last message widget after it faded out until the next message was shown. Hand the widget over to the fade out and make sure the returned disposable doesn't reference it after it completes.

Related to microsoft#146841

Co-authored-by: Copilot <[email protected]>
(cherry picked from commit ee77861)
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Nov 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

editor-contrib Editor collection of extras freeze-slow-crash-leak VS Code crashing, performance, freeze and memory leak issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants