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

perf: do not double-proxy methods being return over the contextBridge #28285

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

MarshallOfSound
Copy link
Member

Previously a function sent over the bridge would result in a proxy function existing in the other context, sending it back would create a proxy-of-a-proxy and so on. With each successive pass over the bridge it would add another layer of proxy'ing which would get slower and slower. This change ensures that when a method is cleanly passed back over the bridge to it's origin we use the stored "original function" as the return value thus ensuring a max proxy depth of 1.

This is safe to do for function because the lifetime of the proxy function is already tied to the lifetime of the original function. We can't do this for others objects / types without some smarts and last time we tried to implement those smarts it caused massive issues.

Notes: Improved performance characteristics of functions being sent back and forth over the contextBridge.

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 18, 2021
@MarshallOfSound MarshallOfSound added performance 🏁 semver/patch backwards-compatible bug fixes labels Mar 18, 2021
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Mar 19, 2021
@jkleinsc jkleinsc requested a review from nornagon March 23, 2021 14:53
@nornagon nornagon merged commit 7918ddb into master Mar 24, 2021
@release-clerk
Copy link

release-clerk bot commented Mar 24, 2021

Release Notes Persisted

Improved performance characteristics of functions being sent back and forth over the contextBridge.

@nornagon nornagon deleted the double-bridge-fn-perf branch March 24, 2021 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance 🏁 semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants