Fix how rpc-server releases references after page reload
In addition to listening for "render-view-deleted", listen for "ELECTRON_BROWSER_CONTEXT_RELEASE" synchronous message, which is sent by the remote module when the page is about to be navigated. This is required to allow child windows running in the same renderer to correctly manage remote object references, since `render-view-deleted` is only called when the renderer exits. Close #9387
This commit is contained in:
parent
22099747af
commit
6b5bd3b6ce
2 changed files with 9 additions and 0 deletions
|
@ -394,6 +394,11 @@ ipcMain.on('ELECTRON_BROWSER_DEREFERENCE', function (event, id) {
|
|||
objectsRegistry.remove(event.sender.getId(), id)
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_CONTEXT_RELEASE', (e) => {
|
||||
objectsRegistry.clear(e.sender.getId())
|
||||
e.returnValue = null
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, guestInstanceId) {
|
||||
try {
|
||||
let guestViewManager = require('./guest-view-manager')
|
||||
|
|
|
@ -304,6 +304,10 @@ ipcRenderer.on('ELECTRON_RENDERER_RELEASE_CALLBACK', function (event, id) {
|
|||
callbacksRegistry.remove(id)
|
||||
})
|
||||
|
||||
process.on('exit', () => {
|
||||
ipcRenderer.sendSync('ELECTRON_BROWSER_CONTEXT_RELEASE')
|
||||
})
|
||||
|
||||
// Get remote module.
|
||||
exports.require = function (module) {
|
||||
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_REQUIRE', module))
|
||||
|
|
Loading…
Reference in a new issue