From 6a7a362409895bfef98845d3e5760ecb80c5b5a9 Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Tue, 29 Mar 2016 12:38:42 +0200 Subject: [PATCH] Always disable web worker for PDF.js and no longer rely on PDF.js catching the execption when the worker cannot be started, fixing Firefox 45+. --- static/js/sandboxes/pdf.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/static/js/sandboxes/pdf.js b/static/js/sandboxes/pdf.js index d38f45cd..f427c3a7 100644 --- a/static/js/sandboxes/pdf.js +++ b/static/js/sandboxes/pdf.js @@ -67,11 +67,16 @@ pdfScript.onload = function(evt) { pdfjs = that.window.PDFJS; if (PDFJS_WORKER_URL) { - // NOTE: the worker script won't actually be run inside a - // real Worker object as it can't be loaded cross-domain - // from the sandboxed iframe ("data:" vs. "https"). pdfjs.workerSrc = PDFJS_WORKER_URL; } + if (true) { + // We currently cannot use a web worker in a sandboxed iFrame + // and in addition to that Firefox 45+ fail with an uncatchable + // exception (see https://bugzilla.mozilla.org/show_bug.cgi?id=1260388) + // So we always disable the worker for now, making PDF.js running + // in fake worker mode. + pdfjs.disableWorker = true; + } console.log("Using pdf.js " + pdfjs.version + " (build " + pdfjs.build + ")"); that._doOpenFile(source); };