fix: memory leak in desktopCapturer.getSources (#27031)

This commit is contained in:
Jeremy Rose 2020-12-16 16:11:39 -08:00 committed by GitHub
parent 8f9058ea72
commit 6a3679dc55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,6 +48,9 @@ export const getSourcesImpl = (event: Electron.IpcMainEvent | null, args: Electr
}
// Remove from currentlyRunning once we resolve or reject
currentlyRunning = currentlyRunning.filter(running => running.options !== options);
if (event) {
event.sender.removeListener('destroyed', stopRunning);
}
};
capturer._onerror = (error: string) => {
@ -66,7 +69,7 @@ export const getSourcesImpl = (event: Electron.IpcMainEvent | null, args: Electr
// reference to emit and the capturer itself so that it never dispatches
// back to the renderer
if (event) {
event.sender.once('destroyed', () => stopRunning());
event.sender.once('destroyed', stopRunning);
}
});