Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1948741

Browse files
Snuffleupaguspull[bot]
authored andcommittedSep 13, 2022
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.
1 parent be89e18 commit 1948741

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed
 

‎src/display/api.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2120,11 +2120,10 @@ class PDFWorker {
21202120
// Right now, the requirement is, that an Uint8Array is still an
21212121
// Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
21222122
if (
2123-
typeof Worker !== "undefined" &&
21242123
!PDFWorkerUtil.isWorkerDisabled &&
21252124
!PDFWorker._mainThreadWorkerMessageHandler
21262125
) {
2127-
let workerSrc = PDFWorker.workerSrc;
2126+
let { workerSrc } = PDFWorker;
21282127

21292128
try {
21302129
// Wraps workerSrc path into blob URL, if the former does not belong
@@ -2299,7 +2298,10 @@ class PDFWorker {
22992298
if (GlobalWorkerOptions.workerSrc) {
23002299
return GlobalWorkerOptions.workerSrc;
23012300
}
2302-
if (PDFWorkerUtil.fallbackWorkerSrc !== null) {
2301+
if (
2302+
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
2303+
PDFWorkerUtil.fallbackWorkerSrc !== null
2304+
) {
23032305
if (!isNodeJS) {
23042306
deprecated('No "GlobalWorkerOptions.workerSrc" specified.');
23052307
}

0 commit comments

Comments
 (0)
Please sign in to comment.