fix double-freeing remote references
After the page does navigations, garbage collection can still happen in the old context. This commit changes to store references to remote objects by _pages_, instead of by _WebContents_.
This commit is contained in:
parent
9cbbb2a6c4
commit
4cdb1b8fc3
9 changed files with 139 additions and 113 deletions
|
@ -8,6 +8,9 @@ const webViewConstants = require('./web-view-constants')
|
|||
|
||||
const hasProp = {}.hasOwnProperty
|
||||
|
||||
// An unique ID that can represent current context.
|
||||
const contextId = v8Util.getContextId()
|
||||
|
||||
// ID generator.
|
||||
let nextId = 0
|
||||
|
||||
|
@ -396,7 +399,7 @@ const registerWebViewElement = function () {
|
|||
const createNonBlockHandler = function (m) {
|
||||
return function (...args) {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
ipcRenderer.send('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m, ...args)
|
||||
ipcRenderer.send('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', contextId, null, internal.guestInstanceId, m, ...args)
|
||||
}
|
||||
}
|
||||
for (const method of nonblockMethods) {
|
||||
|
@ -410,7 +413,7 @@ const registerWebViewElement = function () {
|
|||
hasUserGesture = false
|
||||
}
|
||||
const requestId = getNextId()
|
||||
ipcRenderer.send('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', requestId, internal.guestInstanceId, 'executeJavaScript', code, hasUserGesture)
|
||||
ipcRenderer.send('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', contextId, requestId, internal.guestInstanceId, 'executeJavaScript', code, hasUserGesture)
|
||||
ipcRenderer.once(`ELECTRON_RENDERER_ASYNC_CALL_TO_GUEST_VIEW_RESPONSE_${requestId}`, function (event, result) {
|
||||
if (callback) callback(result)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue