Ensure that the Cmd/Name/Ref caches are cleared when terminating the worker (PR 10863 follow-up)

Usually when the worker is terminated it will also be completely destroyed/removed, which means that any global caches (such as the ones in `src/core/primitive.js`) should be automatically cleared in the process.

However, for certain ways of loading the `pdf.worker.js` file, e.g. passing in a re-usable worker to `getDocument`, using the `workerPort` functionality, or even disabling workers completely  (even though this is never a good idea), the worker file may be kept in memory and these caches will not be cleared as expected.
This commit is contained in:
Jonas Jenwald 2019-05-30 18:38:10 +02:00
parent d0892e46e2
commit a3742a9f83

View File

@ -19,10 +19,10 @@ import {
PasswordException, setVerbosityLevel, UnexpectedResponseException,
UnknownErrorException, UNSUPPORTED_FEATURES, VerbosityLevel, warn
} from '../shared/util';
import { clearPrimitiveCaches, Ref } from './primitives';
import { LocalPdfManager, NetworkPdfManager } from './pdf_manager';
import isNodeJS from '../shared/is_node';
import { MessageHandler } from '../shared/message_handler';
import { Ref } from './primitives';
import { XRefParseException } from './core_utils';
var WorkerTask = (function WorkerTaskClosure() {
@ -700,6 +700,7 @@ var WorkerMessageHandler = {
if (cancelXHRs) {
cancelXHRs();
}
clearPrimitiveCaches();
var waitOn = [];
WorkerTasks.forEach(function (task) {