Skip to content

chore: backport cppgc cleanups - #50915

Merged
deepak1556 merged 2 commits into
41-x-yfrom
robo/fix_gc_plugin_errors_41_x_y
Apr 15, 2026
Merged

deepak1556 merged 2 commits into
41-x-yfrom
robo/fix_gc_plugin_errors_41_x_y

Conversation

@deepak1556

Copy link
Copy Markdown
Member

Description of Change

Backport of #50465

Minus the gc plugin changes

Release Notes

Notes: none

@trop trop Bot mentioned this pull request Apr 10, 2026
@trop
trop Bot requested a review from a team April 10, 2026 20:19
@trop trop Bot added 41-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels Apr 10, 2026
@deepak1556
deepak1556 force-pushed the robo/fix_gc_plugin_errors_41_x_y branch from 2143eef to ad4bb32 Compare April 10, 2026 20:56

@ckerr ckerr left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failing to build here:

2026-04-10T23:44:35.3098520Z In file included from ../../electron/shell/browser/api/electron_api_tray.cc:24:
2026-04-10T23:44:35.3695290Z ##[error]../../electron/shell/common/gin_helper/handle.h:25:17: error: static assertion failed due to requirement '!cppgc::IsGarbageCollectedTypeVelectron::api::Menu': gin_helper::Handle must not be used with cppgc garbage-collected types. Use T* directly instead.
2026-04-10T23:44:35.3707560Z 25 | static_assert(!cppgc::IsGarbageCollectedTypeV,
2026-04-10T23:44:35.3708010Z | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2026-04-10T23:44:35.3709450Z ../../electron/shell/browser/api/electron_api_tray.cc:377:28: note: in instantiation of template class 'gin_helper::Handleelectron::api::Menu' requested here
2026-04-10T23:44:35.3710070Z 377 | gin_helper::Handle

menu;
2026-04-10T23:44:35.3710380Z | ^
2026-04-10T23:44:35.3710660Z 1 error generated.
2026-04-10T23:44:35.3710800Z
2026-04-10T23:44:35.3710800Z
2026-04-10T23:44:35.6462010Z build failed

@deepak1556
deepak1556 requested a review from ckerr April 11, 2026 15:38
Key fixes:
- Replace `base::WeakPtrFactory` with `gin::WeakCellFactory` in
  MenuMac, MenuViews, and NetLog, since weak pointers to cppgc-managed
  objects must go through weak cells
- Replace `v8::Global<v8::Value>` with `cppgc::Persistent<Menu>` for
  the menu reference in BaseWindow
- Stop using `gin_helper::Handle<T>` with cppgc types; use raw `T*`
  and add a `static_assert` to prevent future misuse
- Add proper `Trace()` overrides for Menu, MenuMac, MenuViews, and
  NetLog to ensure cppgc members are visited during garbage collection
- Replace `SelfKeepAlive` prevent-GC mechanism in Menu with a
  `cppgc::Persistent` prevent-GC captured in `BindSelfToClosure`
- Introduce `GC_PLUGIN_IGNORE` macro to suppress
  known-safe violations: mojo::Remote fields, ObjC bridging pointers,
  and intentional persistent self-references
- Mark `ArgumentHolder` as `CPPGC_STACK_ALLOCATED()` in both Electron's
  and gin's function_template.h to silence raw-pointer-to-GC-type
  warnings
@deepak1556
deepak1556 force-pushed the robo/fix_gc_plugin_errors_41_x_y branch from 1db3261 to 2fef39d Compare April 14, 2026 17:23
@deepak1556

deepak1556 commented Apr 15, 2026 •

Copy link
Copy Markdown
Member Author

Failing tests are unrelated and addressed in dad4ab6, merging.

@deepak1556
deepak1556 merged commit 04f4d4b into 41-x-y Apr 15, 2026
61 of 62 checks passed
@deepak1556
deepak1556 deleted the robo/fix_gc_plugin_errors_41_x_y branch April 15, 2026 07:39
@release-clerk

release-clerk Bot commented Apr 15, 2026

Copy link
Copy Markdown

No Release Notes

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants