Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecate ipcRenderer.sendTo() #39091

Merged
merged 3 commits into from Jul 21, 2023

Conversation

miniak
Copy link
Contributor

@miniak miniak commented Jul 13, 2023

Description of Change

It's not possible to do proper validation of the sender in the renderer receiving the IPC as only the senderId is available, but not the senderFrame. This is a concern when nodeIntegrationInSubFrames is enabled in the originating renderer. The API can also only send the IPC to the main frame in the receiver.

This API is redundant as it can be easily replaced by sharing a MessageChannel between the two renderers. The main process can validate the senderFrame before forwarding the MessagePort to the other renderer. Performance should also be better as a direct mojo connection is established between the renderers, instead of the IPC being proxied by the main process.

This API does not seem to be used much: https://github.com/search?q=ipcRenderer.sendTo&type=code
Related to #38868

Checklist

Release Notes

Notes: The ipcRenderer.sendTo() API has been deprecated in favor of sharing a MessageChannel between two renderers.

@miniak miniak requested a review from a team as a code owner July 13, 2023 13:48
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Jul 13, 2023
@miniak miniak self-assigned this Jul 13, 2023
@miniak miniak added semver/minor backwards-compatible functionality no-backport labels Jul 13, 2023
Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Member

@codebytere codebytere left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Member

@dsanders11 dsanders11 left a comment

Choose a reason for hiding this comment

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

Let's also add _Deprecated_ to the end of this line in the docs:

### `ipcRenderer.sendTo(webContentsId, channel, ...args)`

@miniak
Copy link
Contributor Author

miniak commented Jul 18, 2023

Let's also add _Deprecated_ to the end of this line in the docs:

### `ipcRenderer.sendTo(webContentsId, channel, ...args)`

@dsanders11 done

@codebytere codebytere merged commit ada8eb3 into main Jul 21, 2023
15 checks passed
@codebytere codebytere deleted the miniak/deprecate-ipc-renderer-send-to branch July 21, 2023 09:16
@release-clerk
Copy link

release-clerk bot commented Jul 21, 2023

Release Notes Persisted

The ipcRenderer.sendTo() API has been deprecated in favor of sharing a MessageChannel between two renderers.

MrHuangJser pushed a commit to MrHuangJser/electron that referenced this pull request Dec 11, 2023
* feat: deprecate ipcRenderer.sendTo()

* docs: add _Deprecated_ to ipcRenderer.sendTo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants