From a49f496159dbd79f9bdb5ea640f39bc2fb51e921 Mon Sep 17 00:00:00 2001 From: Brett Sun Date: Thu, 28 May 2020 23:58:35 +0200 Subject: [PATCH] Worker: delay object URL clean up (#1430) --- src/worker/SandboxedWorker.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/worker/SandboxedWorker.js b/src/worker/SandboxedWorker.js index 171e398ae..f2a3fe115 100644 --- a/src/worker/SandboxedWorker.js +++ b/src/worker/SandboxedWorker.js @@ -111,8 +111,13 @@ class SandboxedWorker extends EventTarget { } }) - // Clean up the url we created to spawn the worker - URL.revokeObjectURL(workerUrl) + window.addEventListener('unload', () => { + // Clean up the url we created to spawn the worker when the iframe is unloaded + // Note that we **NEED** to do this late, as Chrome 83+ appears to have + // introduced a race condition with starting workers using object URLs, + // preventing us from synchronously revoking this object URL immediately. + URL.revokeObjectURL(workerUrl) + }) } init()