fix: use render client id to track deleted render process hosts (#14520)

* fix: use render client id to track deleted render process hosts

Instead of relying on OS process id, which may not be unique
when a process is reused, we rely on the renderer client id
passed by the content layer when starting the renderer process
which is guaranteed to be unique for the lifetime of the app.

* fix: store context id as int64_t

Ensuring that it doesn't wrap easily with a large number
of context creation on some malformed web pages.
This commit is contained in:
Robo 2018-09-11 23:48:10 +05:30 committed by Shelley Vohr
parent 2157d09956
commit 14ed71fa1b
5 changed files with 27 additions and 31 deletions

View file

@ -87,9 +87,6 @@ class ObjectsRegistry {
// Private: Dereference the object from store.
dereference (id) {
// FIXME(MarshallOfSound): We should remove this once remote deref works well
if (process.env.ELECTRON_DISABLE_REMOTE_DEREFERENCING) return
let pointer = this.storage[id]
if (pointer == null) {
return
@ -103,10 +100,11 @@ class ObjectsRegistry {
// Private: Clear the storage when renderer process is destroyed.
registerDeleteListener (webContents, contextId) {
// contextId => ${OSProcessId}-${contextCount}
const OSProcessId = contextId.split('-')[0]
const listener = (event, deletedProcessId, deletedOSProcessId) => {
if (deletedOSProcessId && deletedOSProcessId.toString() === OSProcessId) {
// contextId => ${processHostId}-${contextCount}
const processHostId = contextId.split('-')[0]
const listener = (event, deletedProcessHostId) => {
if (deletedProcessHostId &&
deletedProcessHostId.toString() === processHostId) {
webContents.removeListener('render-view-deleted', listener)
this.clear(webContents, contextId)
}