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

Check isEvalSupported, and test that eval is actually supported, before attempting to use the PostScriptCompiler (issue 5573) #8909

Merged
merged 1 commit into from
Sep 16, 2017

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Sep 14, 2017

Currently PDFFunction is implemented (basically) like a class with only static methods. Since it's used directly in a number of different src/core/ files, attempting to pass in isEvalSupported would result in code that's very messy, not to mention difficult to maintain (since every single PDFFunction method call would need to include a isEvalSupported argument).

Rather than having to wait for a possible re-factoring of PDFFunction that would avoid the above problems by design, it probably makes sense to at least set isEvalSupported globally for PDFFunction.

Please note that there's one caveat with this solution: If PDFJS.getDocument is used to open multiple files simultaneously, with different PDFJS.isEvalSupported values set before each call, then the last one will always win.
However, that seems like enough of an edge-case that we shouldn't have to worry about it. Besides, since we'll also test that eval is actually supported, it should be fine.

Fixes #5573.

Supersedes PR #8815 (since that one hasn't seen any activity for weeks, and based on the findings above I'm no longer entirely convinced that it would have been a simple beginner bug).

Edit: Slightly smaller diff with https://github.com/mozilla/pdf.js/pull/8909/files?w=1.

…before attempting to use the `PostScriptCompiler` (issue 5573)

Currently `PDFFunction` is implemented (basically) like a class with only `static` methods. Since it's used directly in a number of different `src/core/` files, attempting to pass in `isEvalSupported` would result in code that's *very* messy, not to mention difficult to maintain (since *every* single `PDFFunction` method call would need to include a `isEvalSupported` argument).

Rather than having to wait for a possible re-factoring of `PDFFunction` that would avoid the above problems by design, it probably makes sense to at least set `isEvalSupported` globally for `PDFFunction`.

Please note that there's one caveat with this solution: If `PDFJS.getDocument` is used to open multiple files simultaneously, with *different* `PDFJS.isEvalSupported` values set before each call, then the last one will always win.
However, that seems like enough of an edge-case that we shouldn't have to worry about it. Besides, since we'll also test that `eval` is actually supported, it should be fine.

Fixes 5573.
@Snuffleupagus Snuffleupagus changed the title Check isEvalSupported, and test that eval is actually supported, before attempting to use the PostScriptCompiler Check isEvalSupported, and test that eval is actually supported, before attempting to use the PostScriptCompiler (issue 5573) Sep 15, 2017
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

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/150e7767b924fdc/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/d24f22669906923/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/150e7767b924fdc/output.txt

Total script time: 16.69 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/d24f22669906923/output.txt

Total script time: 29.81 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

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/7f5c455b637092e/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/7f5c455b637092e/output.txt

Total script time: 2.34 mins

Published

@timvandermeij timvandermeij merged commit 3be941d into mozilla:master Sep 16, 2017
@timvandermeij
Copy link
Contributor

Looks good. Given the current state of that code, I agree that this is the nicest solution for now.

@Snuffleupagus Snuffleupagus deleted the PDFFunction-isEvalSupported branch September 17, 2017 08:20
@yurydelendik
Copy link
Contributor

Worker can handle multiple documents and handling isEvalSupported this way may cause confusion. When need to 1) make PDFFunction factory, which is constructed based on isEvalSupported passed to worker, 2) or, pass it similar to verbosity option.

@Snuffleupagus
Copy link
Collaborator Author

Worker can handle multiple documents and handling isEvalSupported this way may cause confusion. When need to 1) make PDFFunction factory, which is constructed based on isEvalSupported passed to worker,

Sure, I'm currently looking into re-factoring PDFFunction and related code to fix this properly.

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