Skip to content

fix: release the floating panel's closed views by drawing the stage with repeat instead of keyed - #7541

Merged
max-sixty merged 1 commit into
mainfrom
fix/issue-7526
Nov 28, 2026
Merged

max-sixty merged 1 commit into
mainfrom
fix/issue-7526

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

#7420 drew the floating panel's stage with Lit's keyed, keyed by the opening, so each opening gets a fresh view node. When the key changes, keyed resets the part's committed value to a sentinel before the new value commits (lit-html 3.3's directives/keyed.js, also on Lit's main). So the old template instance never leaves the part's set of disconnectable children, and the ref(declareView) on that view keeps the whole closed view alive. Every view the panel drew stayed in memory. Opening and closing the versions menu kept about 61 nodes and one listener per round trip, which the closed-surfaces journey of test_page_fixture_renders reported on 50 corpus pages.

The stage now draws a one-item repeat keyed by the opening, the primitive it used before #7420. repeat disposes the old item's part. Each opening still draws its view in a node of its own, so nothing the user sees changes. A comment at the site says why keyed isn't used there.

Verification

How the retainer was found

I diffed two heap snapshots, taken around one round trip once the test harness had drained its own input records. Every old .lf-fp-view[data-lf-route="versions"] was retained by the panel's root part: _$committedValue → stage ChildPart._$disconnectableChildren (a Set that grows by one template instance per opening) → the instance's ElementPart → the view <div>.

Other keyed sites in the tree (records/thread/messages.js, On's regrouping in floating-panel.js, lf-diff, the Playwright timeline) leak the same way only where a ref or another async directive sits under the key, and only when their key changes, which is far rarer than a panel view change. I left them alone.

Closes #7526 — automated triage

…th repeat, not keyed

#7420 drew the stage's one view with Lit's `keyed`, keyed by the
opening. When the key changes, `keyed` resets the part's committed value
to a sentinel before the next value commits, so the old template instance
never leaves the part's set of disconnectable children, and the `ref` on
the view keeps the whole view alive. Each view the panel ever drew stayed
in memory: opening and closing the versions menu kept about 61 nodes and
one listener per round trip, which the render gate's closed-surfaces
journey reported on 50 corpus pages.

The stage now draws a one-item `repeat` keyed by the opening, the
primitive it used before #7420, which disposes the old item's part. Each
opening still gets a node of its own. Nothing the user sees changes.

test_page_fixture_renders[alert-thresholds] fails at the base with the
leak and passes here; alert-review loses the leak finding, keeping only
its separate resize finding.

Closes #7526
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.

test_page_fixture_renders: the versions menu leaks nodes and listeners on 50 corpus pages since #7420

2 participants