Repository navigation
fix(renderer): stop the WebGL cursor-blink interval when releasing the addon (#421) - #433
Conversation
|
Soak results with the fix: same isolated 1-hour run that reproduced the leak (3×3 panes of agent-style output, one workspace closed and reopened per cycle, window kept rendering).
The "after" build also included the separate hidden-window fix (follow-up PR). That one only acts while the window is occluded, which this run avoided, so the difference above is this change. Marking ready for review. |
…e addon (amirlehmam#421) @xterm/addon-webgl 0.19.0 never disposes WebglRenderer's cursor-blink manager (xtermjs/xterm.js#5818). Its 600 ms interval outlives the addon and keeps the renderer and the whole Terminal, scrollback included, reachable. wmux releases WebGL on every hide and close, so each one leaked a Terminal, and renderer memory climbed for as long as panes were switched or closed. Clear the manager before disposing the addon, on both the hide/close and the context-loss paths. The field is private, so the access is guarded, and a test pins it to the shipped build: it fails if the field is renamed, or once the addon registers the manager itself and this workaround can go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
744c065 to
11ec37d
Compare
|
Thank you, this is the leak. I checked it against the shipped 0.19.0 build: 2.55.1 moved every WebGL dispose into |
Refs #421 (draft, verification in progress)
Cause:
@xterm/addon-webgl0.19.0 never disposesWebglRenderer's cursor-blink manager (xtermjs/xterm.js#5818, fixed upstream but not in any stable release). Its 600 ms interval outlives the addon and keeps the renderer and the whole Terminal, scrollback included, alive. wmux releases WebGL on every hide and close of a terminal, so each hide or close of a focused terminal leaked one Terminal. This matches the report: memory grows while you work and stays flat when the app is left alone, it's mostly native memory, and closing workspaces frees nothing.Fix: clear the blink manager before disposing the addon, on both the hide/close path and the context-loss path. The field is private, so the access is guarded. A test pins it to the shipped addon build and fails if the field is renamed, or once the addon fixes the leak itself and this workaround can be removed.
Evidence so far: an isolated 1-hour soak (3×3 panes running agent-style output, one workspace closed and reopened per cycle) reproduced the leak. Post-GC private memory grew about 14 MB per cycle, and 15 xterm cores were alive with 9 terminals open. Heap retainer paths for every leaked core ran through the blink interval.
Still to do before ready for review: finish the same soak with this fix and post the numbers. A separate PR will follow for a smaller hidden-window-only retention (one-shot rAFs never cancelled on unmount).
🤖 Generated with Claude Code