From a576ea216ffcaf080f6ebbaec4bce72776d45b4a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 14 Oct 2022 16:43:49 +0200 Subject: [PATCH] Don't trigger worker-thread cleanup when destruction has already started Note how we're currently skipping all main-thread cleanup when document destruction has started, but for some reason we're still dispatching the "Cleanup" message. This seems like a simple oversight, since destruction will already invoke the `BasePdfManager.cleanup` method (on the worker-thread) to fully clear-out all caches. --- src/display/api.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/display/api.js b/src/display/api.js index 0fff1a79c..9ab632bfa 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2997,11 +2997,11 @@ class WorkerTransport { } async startCleanup(keepLoadedFonts = false) { - await this.messageHandler.sendWithPromise("Cleanup", null); - if (this.destroyed) { return; // No need to manually clean-up when destruction has started. } + await this.messageHandler.sendWithPromise("Cleanup", null); + for (const page of this.#pageCache.values()) { const cleanupSuccessful = page.cleanup();