Skip to content

fix: keep remote api::WebContents alive while their content::WebContents lives - #52904

Merged
MarshallOfSound merged 2 commits into
44-x-yfrom
trop/44-x-y-bp-fix-keep-remote-api-webcontents-alive-while-their-content-webcontents-lives-1786967010850
Aug 17, 2026
Merged

MarshallOfSound merged 2 commits into
44-x-yfrom
trop/44-x-y-bp-fix-keep-remote-api-webcontents-alive-while-their-content-webcontents-lives-1786967010850

Conversation

@trop

@trop trop Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Backport of #52847

See that PR for details.

Notes: Fixed a rare crash in the main process when DevTools were opened and a garbage collection ran before the DevTools frontend finished loading.

trop Bot and others added 2 commits August 17, 2026 11:43
…nts lives

The api::WebContents wrapping a DevTools WebContents is created up front in
InspectableWebContents::ShowDevTools but only referenced again once the
frontend has loaded. It is a kRemote WebContents, so nothing pinned it and a
GC in between collected its wrapper; DevToolsOpened() then either got an
empty handle back from FromOrCreate() and crashed dereferencing it, or
created a second api::WebContents for the same DevTools WebContents.

Pin remote api::WebContents in the constructor and unpin them in
WebContentsDestroyed(), the same mechanism background pages already use.

Fixes #52158

Co-authored-by: Samuel Attard <[email protected]>
No-Verification-Needed: formatting-only change

Co-authored-by: Samuel Attard <[email protected]>
@trop
trop Bot requested a review from MarshallOfSound August 17, 2026 11:44
@trop trop Bot added 44-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Aug 17, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) August 17, 2026 11:47
@MarshallOfSound
MarshallOfSound merged commit 374a1a9 into 44-x-y Aug 17, 2026
90 checks passed
@MarshallOfSound
MarshallOfSound deleted the trop/44-x-y-bp-fix-keep-remote-api-webcontents-alive-while-their-content-webcontents-lives-1786967010850 branch August 17, 2026 13:04
@release-clerk

release-clerk Bot commented Aug 17, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed a rare crash in the main process when DevTools were opened and a garbage collection ran before the DevTools frontend finished loading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

44-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant