Repository navigation
fix: release the floating panel's closed views by drawing the stage with repeat instead of keyed - #7541
Merged
Conversation
…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
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.
#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,keyedresets the part's committed value to a sentinel before the new value commits (lit-html3.3'sdirectives/keyed.js, also on Lit'smain). So the old template instance never leaves the part's set of disconnectable children, and theref(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 oftest_page_fixture_rendersreported on 50 corpus pages.The stage now draws a one-item
repeatkeyed by the opening, the primitive it used before #7420.repeatdisposes 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 whykeyedisn't used there.Verification
test_page_fixture_renders[alert-thresholds]fails at the base withthe versions menu leaks nodes: [5302, 5363, 5424, 5485]and passes here.[feature-gallery]passes too.[alert-review]loses the leak finding but still fails on a resize finding that bisects to Port lf-options to Effect UI as the first decorating widget #7417. fix: read lf-options' members and shadow-root controls in the link preview and render gate #7538 doesn't fix that one, so I filed it as test_page_fixture_renders[alert-review]: an lf-option's strong keeps a wider box after a resize round trip since #7417 #7540.alert-review, six versions-menu round trips held 6613 → 7240 nodes at the base, and stay at 6878 here after the first trip.pnpm run test:runtime(1237 pass), pre-commit, and 25 focused panel, Go-to and On tests pass.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→ stageChildPart._$disconnectableChildren(aSetthat grows by one template instance per opening) → the instance'sElementPart→ the view<div>.Other
keyedsites in the tree (records/thread/messages.js, On's regrouping infloating-panel.js,lf-diff, the Playwright timeline) leak the same way only where arefor 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