Skip to content

[api-minor] Remove the closure from the PDFWorker class, in the src/display/api.js file #13882

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

Merged
merged 1 commit into from
Aug 7, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

This patch removes the only remaining closure in the src/display/api.js file, utilizing a similar approach as used in lots of other parts of the code-base, which results in a small decrease in the size of the build pdf.js file.

Given that PDFWorker is exposed through the public API, this complicates things somewhat since there's a couple of worker-related properties that really should stay private. Initially, while working on PR #13813, I believed that we'd need support for private (static) class fields in order to get rid of this closure, however I've managed to come up with what's hopefully deemed an acceptable work-around here.
Furthermore, some helper functions were simply moved into the PDFWorker class as static methods, thus simplifying the overall implementation (e.g. we don't need to manually cache the Promise in the PDFWorker._setupFakeWorkerGlobal-method).

Finally, as part of this re-factoring a number of missing JSDoc-comments were added which together with the removal of the closure significantly improves the gulp jsdoc output for the PDFWorker class.

Please note: This patch is tagged with api-minor since it deprecates PDFWorker.getWorkerSrc() in favor of the shorter PDFWorker.workerSrc, with the fallback limited to GENERIC builds.

@Snuffleupagus Snuffleupagus force-pushed the PDFWorker-rm-closure branch 3 times, most recently from 4a0b732 to 78ddb42 Compare August 7, 2021 08:39
…c/display/api.js` file

This patch removes the only remaining closure in the `src/display/api.js` file, utilizing a similar approach as used in lots of other parts of the code-base, which results in a small decrease in the size of the *build* `pdf.js` file.

Given that `PDFWorker` is exposed through the *public* API, this complicates things somewhat since there's a couple of worker-related properties that really should stay *private*. Initially, while working on PR 13813, I believed that we'd need support for private (static) class fields in order to get rid of this closure, however I've managed to come up with what's hopefully deemed an acceptable work-around here.
Furthermore, some helper functions were simply moved into the `PDFWorker` class as static methods, thus simplifying the overall implementation (e.g. we don't need to manually cache the Promise in the `PDFWorker._setupFakeWorkerGlobal`-method).

Finally, as part of this re-factoring a number of missing JSDoc-comments were added which *together* with the removal of the closure significantly improves the `gulp jsdoc` output for the `PDFWorker` class.

*Please note:* This patch is tagged with `api-minor` since it deprecates `PDFWorker.getWorkerSrc()` in favor of the shorter `PDFWorker.workerSrc`, with the fallback limited to `GENERIC` builds.
@Snuffleupagus Snuffleupagus marked this pull request as ready for review August 7, 2021 09:05
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Aug 7, 2021

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/31db561b8574bdf/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 7, 2021

From: Bot.io (Windows)


Received

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

Live output at: http://3.101.106.178:8877/e4d225ec7d6f395/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 7, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/31db561b8574bdf/output.txt

Total script time: 33.65 mins

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

Image differences available at: http://54.67.70.0:8877/31db561b8574bdf/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

pdfjsbot commented Aug 7, 2021

From: Bot.io (Windows)


Failed

Full output at http://3.101.106.178:8877/e4d225ec7d6f395/output.txt

Total script time: 39.00 mins

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

Image differences available at: http://3.101.106.178:8877/e4d225ec7d6f395/reftest-analyzer.html#web=eq.log

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Aug 7, 2021

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/be53d16d3ec4cd5/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 7, 2021

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/be53d16d3ec4cd5/output.txt

Total script time: 5.24 mins

Published

@timvandermeij timvandermeij merged commit 036b814 into mozilla:master Aug 7, 2021
@timvandermeij
Copy link
Contributor

Looks good to me; thank you for doing this!

@Snuffleupagus Snuffleupagus deleted the PDFWorker-rm-closure branch August 7, 2021 18:05
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.

3 participants