Open mykmelez opened 8 years ago
"this process", "other process" … I'm confused.
Could you rephrase using "process A" and "process B", @mykmelez?
Could you rephrase using "process A" and "process B", @mykmelez?
I can, but there are actually two (related) use cases, one in process A and the other in process B, so perhaps it would be better to get more specific:
Use Case 1:
When a "renderer" process creates a "delegate object" to represent an object in the "main" (a.k.a. "browser") process, it calls v8Utils.setDestructor to register a JavaScript callback on the delegate:
Upon destruction of the delegate, that callback sends a message to the main process, which removes the object from a registry of objects:
Use Case 2:
When the main process creates a "callIntoRenderer function" to represent a function in a renderer process, it calls v8Utils.setDestructor to register a JavaScript callback on the function:
Upon destruction of the function, that callback sends a message to the renderer process, which removes the object from a registry of callbacks:
Thanks for clarifying!
As discussed in IRC, setDestructor has been removed from electron https://github.com/electron/electron/commit/06cf0406fe8ddcef3a500a689952c77fdfb9c9a8#diff-695530a8eced1fbb2c784d6a52a4290f
Though we'll likely need to support setRemoteCallbackFreer and setRemoteObjectFreer
Electron uses a native API to register JavaScript callbacks on destruction of certain objects:
https://github.com/mozilla/positron/search?l=javascript&q=setDestructor&utf8=%E2%9C%93
Electron uses these callbacks to destroy objects in another process that are proxies or callbacks for the objects being destroyed in this process. We'll need to support these callbacks too, or find another way to ensure that the objects in the other process are destroyed, or else we'll leak the objects in the other process.