Repository navigation
Prune the margin card's thread seat once it has stood in the page, and hold the shift watch's shadow roots weakly - #5316
Merged
Merged
Conversation
…d hold the shift watch's shadow roots weakly Since #4873 the margin card builds a new section and seat body for each thread card it opens. The seat commits while that body is still detached, and its owner places it afterwards (`claimSeatReplies`), so the seat never recorded that it had stood in the page and `prune` never disposed it. Every opened card kept its ThreadSeat in `activeSeats` and its HeldNews in `holders`, and through them the whole card, its nodes and listeners. `claim` is the owner's signal that the seat now stands in the document, so it now records that, and the next commit prunes the card the user closed. The shift watch kept every shadow root ever attached in a strong Set, so a closed card's reply field pinned the card for as long as the test ran, and the render gate's surface round trips read that as the page leaking. It now holds them by WeakRef and still visits each live one, closed roots included. With both, the thread card's round trips hold steady on log-retention, review-a-plan, ship-review, thread-choice-hints, feature-gallery and thread-panel-gallery. Either alone leaves the count climbing. Closes #5190
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.
The render gate's thread-card round trips retained a whole margin card per open on six corpus pages (#5190). This had two retainers, and both had to go before the counts held steady.
inline.js). Since Make strict checking the default for maintained browser modules #4873 the margin card builds a new.lf-margin-threadsection and seat body for each card it opens. Before that change, it reused the one section. The seat commits while the body is still detached, and the owner places it afterwards throughclaimSeatReplies. So#connectedstayed false, andprune()never disposed the seat. Each opened card left itsThreadSeatinactiveSeatsand itsHeldNewsinholders, and those kept the card's nodes and listeners alive. Nowclaim(), the owner's placement signal, records that the seat stands in the document, and the next commit prunes the card the user closed.shift_watch.js). The shift watch kept every shadow root ever attached in a strongSet. A closed card's reply field (leaf-text's shadow root) therefore kept the card alive as long as the page lived, andlive_countsread that as a leak. It now holds roots byWeakRefand still walks every live one, closed roots included. This fixes the measuring instrument and leaves the leak thresholds unchanged.Verification. On main,
test_page_fixture_renders[log-retention]reportsthe thread card leaks nodes: [2210, 2519, 3304, 4089]. With this change, the thread-card leak is gone from log-retention, review-a-plan, ship-review, thread-choice-hints, feature-gallery (nodes and listeners) and thread-panel-gallery. A probe of sixt+ Escape trips on log-retention reads a flat 2871 nodes and 1011 listeners. With only the harness fix it climbs from the third trip, and with only the runtime fix it climbs from the first.git bisectwith that probe over the last passing and first failing nightlies lands on #4873.Those six cases still fail locally on findings this change doesn't touch:
g opened no go-to, on every page, which also happens on unmodified main and is absent from the Nov 3 nightly.apparatus among authored<span>, which the Nov 3 nightly also reports.pnpm run test:runtime(776),check:browser, the shift watch's shadow-root browser tests (23) and the margin card's reply tests pass. The one failure in that selection,test_an_offscreen_thread_card_arrives_with_its_anchor[above-or-below-up], also fails on main (#5146).How the retainers were found
After four round trips,
DOM.getDetachedDomNodeslisted three detachedSECTION.lf-margin-threadtrees of about 280 nodes each, while the attached DOM stayed at 813 nodes. Shortest retainer paths in a heap snapshot (excluding weak and ephemeron edges) ran through the shift watch'srootsSet (ShadowRoot→leaf-text→ … → section). With that scope excluded, they ran throughholders→HeldNews.#seat, the margin card's seat body, withactiveSeatsholding the seat itself.Closes #5190 — automated triage