Skip to content

fix(sidebar): stop auto-animate leaking detached rows via IntersectionObserver (#1475) - #1490

Merged
currentbits merged 2 commits into
mainfrom
coder/perf-h-heap-renderer-heap-growth-3944b5
Oct 6, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/perf-h-heap-renderer-heap-growth-3944b5

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Part of #1475, round 3. The end-to-end measurement (docs/perf/2026-10-06-end-to-end.md) showed renderer heap still climbing during the soak even with DOM bounded. Investigation notes are in docs/perf/2026-10-06-renderer-heap.md.

Leak found: @formkit/auto-animate 0.10 (and the 1.0 betas) re-observes a sidebar row from a debounced timer that can fire after the row has left the DOM. The observer's root is the document element, so Blink keeps the observer, and the detached row subtree its callback closes over, alive for the session. The soak leaked one more observer, +38 DOM nodes and +5 listeners per stream; the same happens on every thread status change.

Fix: skipDetachedObserve() makes IntersectionObserver.prototype.observe a no-op for a target that isn't isConnected. Observing a detached element measures nothing, so no behaviour is lost.

  • I checked that auto-animate is the only IntersectionObserver user, both in src/ and in every runtime dependency.
  • A ponytail: note marks the global patch and says when to drop it.

Measured (worker, development-mode build with production React, headless Chromium, 12-stream soak on the real 1,055-message thread):

  • DOM nodes and listeners are exactly flat from stream 3 to stream 12 (they used to climb every stream).
  • Live observers stay flat at 12; before the fix they went 12 → 24.
  • The heap now grows only by the streamed text itself (~0.1 MB per answer).

Verified independently

Open: the +12 MB heap rise seen in Electron's soak isn't reproduced in the browser (~1.5 MB there), so the rest is likely preload/IPC/thread-list specific. Re-measure in the app after this lands.

🤖 Generated with Claude Code

Willem and others added 2 commits October 6, 2026 12:03
…nObserver (#1475)

auto-animate's debounced updatePos can fire after a row left the DOM and
re-observe it. The observer is rooted at the document element, so Blink
keeps it and the detached row subtree alive for the session: 4-5 leaked
cards/shelves per status change in a soak. Skip observe() on detached
targets; observing them measures nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T10:15:18.150860Z a5df17a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit fd43e86 into main Oct 6, 2026
6 checks passed
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