codebytere

#49998: fix: bind offscreen paint callback to child WebContents

Merged
Created: Mar 2, 2026, 3:22:47 AM
Merged: Mar 2, 2026, 10:24:51 AM
5 comments
Target: main

Description of Change

Refs #47868

Previously, MaybeOverrideCreateParamsForNewWindow bound the OffScreenWebContentsView's paint callback to the parent WebContents using base::Unretained(this). This was both unsafe (dangling pointer risk if the parent is destroyed before the child) and semantically incorrect — paint events belong to the child window, not the opener.

Replace the callback in MaybeOverrideCreateParamsForNewWindow with base::DoNothing(), then rebind it to the child WebContents in AddNewContents via a new SetCallback method on OffScreenWebContentsView.

Checklist

Release Notes

Notes: none

Backports

38-x-y
Pending
Waiting for a manual backport
39-x-y
Pending
Waiting for a manual backport
40-x-y
Merged
PR Number
#50024
Merged At
Mar 3, 2026, 3:43:09 AM
Released In
v40.7.0
Release Date
Mar 3, 2026, 10:03:33 AM
41-x-y
Pending
Waiting for a manual backport

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron