A couple of small PDFWorker changes

- Remove the `typeof Worker` check, since all browsers have had `Worker` support for many years now; see https://developer.mozilla.org/en-US/docs/Web/API/Worker#browser_compatibility
   Furthermore the `new Worker(...)` call is wrapped in try-catch, which means that we'll still fallback to "fake workers" if necessary.

 - Limit the `fallbackWorkerSrc` handling, in the `PDFWorker.workerSrc` getter, to only GENERIC builds since that's the only place where it's defined anyway.
This commit is contained in:
Jonas Jenwald 2022-08-15 11:44:26 +02:00
parent e6fe127433
commit c02d0aa2cb

View File

@ -2120,11 +2120,10 @@ class PDFWorker {
// Right now, the requirement is, that an Uint8Array is still an // Right now, the requirement is, that an Uint8Array is still an
// Uint8Array as it arrives on the worker. (Chrome added this with v.15.) // Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
if ( if (
typeof Worker !== "undefined" &&
!PDFWorkerUtil.isWorkerDisabled && !PDFWorkerUtil.isWorkerDisabled &&
!PDFWorker._mainThreadWorkerMessageHandler !PDFWorker._mainThreadWorkerMessageHandler
) { ) {
let workerSrc = PDFWorker.workerSrc; let { workerSrc } = PDFWorker;
try { try {
// Wraps workerSrc path into blob URL, if the former does not belong // Wraps workerSrc path into blob URL, if the former does not belong
@ -2299,7 +2298,10 @@ class PDFWorker {
if (GlobalWorkerOptions.workerSrc) { if (GlobalWorkerOptions.workerSrc) {
return GlobalWorkerOptions.workerSrc; return GlobalWorkerOptions.workerSrc;
} }
if (PDFWorkerUtil.fallbackWorkerSrc !== null) { if (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
PDFWorkerUtil.fallbackWorkerSrc !== null
) {
if (!isNodeJS) { if (!isNodeJS) {
deprecated('No "GlobalWorkerOptions.workerSrc" specified.'); deprecated('No "GlobalWorkerOptions.workerSrc" specified.');
} }