fix: use OS process handle to clear object registry (#14324)

RenderProcessHost switch can happen between ipc calls when
speculative process are invvolved, which will lead to deletion
of entries on current context. Use OS process handles to
uniquely associate a destruction handler for a render process.
This commit is contained in:
Robo 2018-08-29 00:02:46 +05:30 committed by Charles Kerr
parent 98b7a9ce9c
commit edd5c4b9bb
4 changed files with 10 additions and 7 deletions

View file

@ -103,9 +103,10 @@ class ObjectsRegistry {
// Private: Clear the storage when renderer process is destroyed.
registerDeleteListener (webContents, contextId) {
const processId = webContents.getProcessId()
const listener = (event, deletedProcessId) => {
if (deletedProcessId === processId) {
// contextId => ${OSProcessId}-${contextCount}
const OSProcessId = contextId.split('-')[0]
const listener = (event, deletedProcessId, deletedOSProcessId) => {
if (deletedOSProcessId && deletedOSProcessId.toString() === OSProcessId) {
webContents.removeListener('render-view-deleted', listener)
this.clear(webContents, contextId)
}