Skip to content

chore: remove redundant isolate params in the context bridge - #52569

Merged
jkleinsc merged 3 commits into
mainfrom
chore/cleanup-isolate-params-context-bridge
Aug 7, 2026
Merged

jkleinsc merged 3 commits into
mainfrom
chore/cleanup-isolate-params-context-bridge

Conversation

@dsanders11

@dsanders11 dsanders11 commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

Description of Change

The target_isolate and destination_isolate parameters were plumbed in on #48212 but were left dangling in GetInitiatorContext, so they were dead code. Since contexts are within the same isolate, we shouldn't need to plumb down the target/destination isolate as its always the same as the source isolate - this was confirmed for all existing call sites.

This was initially flagged by the clang-analyzer-deadcode.DeadStores check in clang-tidy, since there's an assignment to target_isolate in GetInitiatorContext that's never read back.

Checklist

  • I have built and tested this change
  • I have filled out the PR description

Release Notes

Notes: none

@dsanders11
dsanders11 requested a review from deepak1556 July 30, 2026 21:11
@dsanders11 dsanders11 added semver/none target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. labels Jul 30, 2026
@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Jul 30, 2026
@dsanders11
dsanders11 marked this pull request as ready for review July 30, 2026 22:14

@deepak1556 deepak1556 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.

Thanks!

It would be worth having a CHECK under PassValueToOtherContext that source and destination context are resolving to same isolate ?

@dsanders11

dsanders11 commented Jul 31, 2026 •

Copy link
Copy Markdown
Member Author

@deepak1556, good suggestion, addressed in 322b724.

EDIT: Actually, I reverted that, rushed it a little too much on the way out the door. It looks like in the latest V8 versions since they removed v8::Context::GetIsolate there's not really a clean way to do a CHECK that both are from the same isolate, but V8 will crash if we touch a context that's not for the current isolate. Claude is convinced there's no tangible benefit to doing an additional CHECK here.

@MarshallOfSound MarshallOfSound 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.

Don't node worker threads ran off of multiple isolates?

@deepak1556

Copy link
Copy Markdown
Member

Right same for web workers as well, my assumption was with the current tests this module does not cross isolate boundaries, the change before this PR was always defaulting to source isolate. What is the scenario you are thinking of with worker threads ?

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jul 31, 2026
@MarshallOfSound

Copy link
Copy Markdown
Member

Given exposeInIsolatedWorld can take any world ID couldn't it technically point at a web worker / node worker? If that never worked (I thought it did because we read isolates of the contexts originally) we should fix it and if we broke it recently we should fix it too 😅

@deepak1556

Copy link
Copy Markdown
Member

I couldn't trace back cross isolate support, our current context extractors are working based off frame associated script states which doesn't have idea about worker threads. Even the service worker preload realms are only operating on same isolate contexts. Given this PR is currently cleaning up an incorrect mechanical change from #48212 when v8::Context::GetIsolate() was deprecated, thoughts on merging this cleanup first. Support for cross isolate would require a resonable change give the proxy wrappers enter contexts synchronously which cannot be safe for cross thread isolates. It could be a followup feature change ?

@dsanders11

Copy link
Copy Markdown
Member Author

@MarshallOfSound, in addition to Deepak's comment, in response to "Given exposeInIsolatedWorld can take any world ID couldn't it technically point at a web worker / node worker?" - isn't this impossible with the current API shape? Ignoring internal implementation details, how would an app developer get a world ID for a web worker using our current API? You can only set a world ID via webFrame.setIsolatedWorldInfo, but there's no webFrame associated with a web worker or node worker.

@jkleinsc
jkleinsc merged commit 87eb85d into main Aug 7, 2026
72 checks passed
@jkleinsc
jkleinsc deleted the chore/cleanup-isolate-params-context-bridge branch August 7, 2026 20:00
@release-clerk

release-clerk Bot commented Aug 7, 2026

Copy link
Copy Markdown

No Release Notes

@trop

trop Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #52703

@trop trop Bot added the in-flight/43-x-y label Aug 7, 2026
@trop

trop Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #52704

@trop trop Bot removed the target/43-x-y PR should also be added to the "43-x-y" branch. label Aug 7, 2026
@trop

trop Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #52705

@trop trop Bot added in-flight/44-x-y in-flight/42-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/44-x-y in-flight/43-x-y in-flight/42-x-y labels Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. semver/none

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants