Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[api-minor] Validate the workerPort/workerSrc options #17504

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

Ensure that users cannot provide incorrect values when trying to set the global worker-options.
This patch was prompted by occasionally seeing users manually loading the pdf.worker.mjs-file and then assigning it to the workerSrc-option, something that obviously doesn't make sense and will cause fake-workers to be used (with poor performance as a result).

Ensure that users cannot provide incorrect values when trying to set the global worker-options.
This patch was prompted by occasionally seeing users manually loading the `pdf.worker.mjs`-file and then assigning it to the `workerSrc`-option, something that obviously doesn't make sense and will cause fake-workers to be used (with poor performance as a result).
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.241.84.105:8877/8b3d79942554442/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.193.163.58:8877/9a90b119a0ead17/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/8b3d79942554442/output.txt

Total script time: 24.31 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 17
  different first/second rendering: 1

Image differences available at: http://54.241.84.105:8877/8b3d79942554442/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/9a90b119a0ead17/output.txt

Total script time: 37.95 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 26

Image differences available at: http://54.193.163.58:8877/9a90b119a0ead17/reftest-analyzer.html#web=eq.log

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you.

@Snuffleupagus Snuffleupagus merged commit 56ca2fd into mozilla:master Jan 13, 2024
9 checks passed
@Snuffleupagus Snuffleupagus deleted the GlobalWorkerOptions-validate branch January 13, 2024 08:23
@mbrevda
Copy link

mbrevda commented Apr 15, 2024

It might have been worth waiting for a major revision for this change as it is likely to break lots of deploys. "make sense" or not, many include/require the worker and pass that as the value, possibly due to this being one of the top hits on Google. Additionally, due to the way bundlers are used these days, it's quite unergonomic and unnatural to include part of a library by "building" (i.e. copying) it separately.

For anyone dealing with this issue:

  • the value of pdfjsLib.GlobalWorkerOptions.workerSrc should to be a string.
  • If node_modules aren't available at run time (e.g. only built files are deployed), the worker at node_modules/pdfjs-dist/build/pdf.worker.js must be included by copying it manually or via a bundler.
  • Set pdfjsLib.GlobalWorkerOptions.workerSrc to the path where the worker can be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants