refactor: remove gin patch to notify microtask runner disposal - #53759
Draft
deepak1556 wants to merge 12 commits into
Draft
refactor: remove gin patch to notify microtask runner disposal#53759deepak1556 wants to merge 12 commits into
deepak1556 wants to merge 12 commits into
Conversation
Following CL https://crrev.com/c/8279909. Remove the worker specific holder registry and let unified heap tracing manage callback lifetimes. Move function and object template caches from isolate scope to gin context data so discarded contexts can be collected. Install lifecycle owned gin context data for Node workers without requiring gin isolate data, and detach it during environment cleanup.
Move the native resources owned by api::WebContents and every native registration that routes callbacks back into it (WebContentsObserver, WebContentsDelegate, InputEventObserver, the InspectableWebContents delegates, BackgroundThrottlingSource and ExclusiveAccessContext) into a nested NativeLifecycle helper that forwards through a weak link. Isolating the native teardown from the wrapper is a prerequisite for managing api::WebContents with cppgc, where the wrapper is reclaimed by the collector instead of being deleted at a well defined point. No behavior change, the wrapper is still a DeprecatedWrappable that is pinned and deleted explicitly.
Move api::WebContents onto the cppgc managed gin::Wrappable, so the wrapper participates in unified heap tracing instead of being pinned and deleted by hand. NativeLifecycle now holds a weak link into the GC heap, registers a dispose observer to drain native resources before isolate shutdown, and is deleted in a follow up task so native teardown never runs during sweeping.
The agent host keeps a raw client pointer. If the Debugger was still attached when cppgc finalized it, a later ForceDetachAllSessions() at quit called AgentHostClosed() on freed memory.
content makes the new host current and can run embedder callbacks (focus/blur from CommitPending) before RenderFrameHostChanged re-keys the existing WebFrameMain, so touching webContents.mainFrame in that window constructed a second instance for the same FrameTreeNode and CHECKed. Also dispose WebFrameMains of a WebContents that api::WebContents stops observing without owning (webview guests, background pages), and replace a stale FrameTreeNode entry instead of CHECKing.
api::WebContents was the last user of gin_helper::DeprecatedWrappable and gin_helper::Pinnable, so drop both along with the generic helper overloads and template bookkeeping that only existed to keep the deprecated wrapper info working. The gin patch that restored the deprecated wrapper utilities can go with them, but the gin::PerIsolateData hook that notifies dispose observers before the microtasks runner is disposed is still needed, so reduce the patch to just that hook.
Comment on lines
83
to
86
| NotificationDelegateProxy(v8::Isolate* isolate, Notification* notification) | ||
| : isolate_(isolate), notification_(notification) { | ||
| gin::PerIsolateData::From(isolate_)->AddDisposeObserver(this); | ||
| MicrotasksRunner::AddObserver(this); | ||
| } |
Member
There was a problem hiding this comment.
Nit: nothing reads isolate_ anymore now that both sides go through MicrotasksRunner, so the member and the v8::Isolate* ctor param can both go.
ckerr
self-requested a review
September 10, 2026 17:55
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.
Description of Change
Refs #47922
Release Notes
Notes: none