1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Ensure that full clean-up is always run when handling the "Terminate" message in src/core/worker.js

This is beneficial in situations where the Worker is being re-used, for example with fake workers, since it ensures that things like font resources are actually released.
This commit is contained in:
Jonas Jenwald 2020-01-16 14:55:08 +01:00
parent 40f531ee87
commit 090ff116d4
2 changed files with 18 additions and 5 deletions

View file

@ -593,16 +593,22 @@ var WorkerMessageHandler = {
handler.on("Terminate", function wphTerminate(data) {
terminated = true;
const waitOn = [];
if (pdfManager) {
pdfManager.terminate(new AbortException("Worker was terminated."));
const cleanupPromise = pdfManager.cleanup();
waitOn.push(cleanupPromise);
pdfManager = null;
} else {
clearPrimitiveCaches();
}
if (cancelXHRs) {
cancelXHRs(new AbortException("Worker was terminated."));
}
clearPrimitiveCaches();
var waitOn = [];
WorkerTasks.forEach(function(task) {
waitOn.push(task.finished);
task.terminate();