Skip to content

[api-minor] Re-factor the *internal* renderingIntent, and change the default intent value in the PDFPageProxy.getAnnotations method #13867

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 2 commits into from
Aug 7, 2021

Conversation

Snuffleupagus
Copy link
Collaborator

With the changes made in PR #13746 the internal renderingIntent handling became somewhat "messy", since we're now having to do string-matching in various spots in order to handle the "oplist"-intent correctly.
Hence this patch, which implements the idea from PR #13746 to convert the intent-strings, used in various API-methods, into an internal renderingIntent that's implemented using a bit-field instead. Please note: This part of the patch, in itself, does not change the public API (but see below).

This patch is tagged api-minor for the following reasons:

  1. It changes the default value for the intent parameter, in the PDFPageProxy.getAnnotations method, to "display" in order to be consistent across the API.
  2. In order to get all annotations, with the PDFPageProxy.getAnnotations method, you now need to explicitly set "any" as the intent parameter.
  3. The PDFPageProxy.getOperatorList method will now also support the new "any" intent, to allow accessing the operatorList of all annotations (limited to those types that have one).
  4. Finally, for consistency across the API, the PDFPageProxy.render method also support the new "any" intent (although I'm not sure how useful that'll be).

Points 1 and 2 above are the significant, and thus breaking, changes in default behaviour here. However, unfortunately I cannot see a good way to improve the overall API while also keeping PDFPageProxy.getAnnotations unchanged.

@mozilla mozilla deleted a comment from pdfjsbot Aug 4, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 4, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 4, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 4, 2021
@Snuffleupagus Snuffleupagus force-pushed the RenderingIntentFlag branch 6 times, most recently from bea737a to b780270 Compare August 5, 2021 09:46
@mozilla mozilla deleted a comment from pdfjsbot Aug 5, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 5, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 5, 2021
@mozilla mozilla deleted a comment from pdfjsbot Aug 5, 2021
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Aug 5, 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/efb9299a492e756/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 5, 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/71a44485f1be365/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Aug 5, 2021

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/71a44485f1be365/output.txt

Total script time: 33.46 mins

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

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

@pdfjsbot
Copy link

pdfjsbot commented Aug 5, 2021

From: Bot.io (Windows)


Failed

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

Total script time: 39.21 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://3.101.106.178:8877/efb9299a492e756/reftest-analyzer.html#web=eq.log

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

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

I like the changes proposed here, but now that we're changing default API behavior it might be a good time to tag this as [api-major] instead and let the next release be version 3.0. This is not only consistent with semantic versioning, but also allows us to get rid of other code that we previously deprecated (in separate patches) since we're doing a major bump. What do you think?

…default `intent` value in the `PDFPageProxy.getAnnotations` method

With the changes made in PR 13746 the *internal* renderingIntent handling became somewhat "messy", since we're now having to do string-matching in various spots in order to handle the "oplist"-intent correctly.
Hence this patch, which implements the idea from PR 13746 to convert the `intent`-strings, used in various API-methods, into an *internal* renderingIntent that's implemented using a bit-field instead. *Please note:* This part of the patch, in itself, does *not* change the public API (but see below).

This patch is tagged `api-minor` for the following reasons:
 1. It changes the *default* value for the `intent` parameter, in the `PDFPageProxy.getAnnotations` method, to "display" in order to be consistent across the API.
 2. In order to get *all* annotations, with the `PDFPageProxy.getAnnotations` method, you now need to explicitly set "any" as the `intent` parameter.
 3. The `PDFPageProxy.getOperatorList` method will now also support the new "any" intent, to allow accessing the operatorList of all annotations (limited to those types that have one).
 4. Finally, for consistency across the API, the `PDFPageProxy.render` method also support the new "any" intent (although I'm not sure how useful that'll be).

Points 1 and 2 above are the significant, and thus breaking, changes in *default* behaviour here. However, unfortunately I cannot see a good way to improve the overall API while also keeping `PDFPageProxy.getAnnotations` unchanged.
…ng, since it's currently subtly wrong

The value of the `renderInteractiveForms` parameter, as passed to the `PDFPageProxy.render` method, will (potentially) affect the size/content of the operatorList that's returned from the worker (for documents with forms).
Given that operatorLists will generally, unless they contain huge images, be cached in the API, repeated `PDFPageProxy.render` calls that *only* change the `renderInteractiveForms` parameter can thus return an incorrect operatorList.

As far as I can tell, this *subtle* bug has existed ever since `renderInteractiveForms`-support was first added in PR 7633 (which is almost five years ago).
With the previous patch, fixing this is now really simple by "encoding" the `renderInteractiveForms` parameter in the *internal* renderingIntent handling.
@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Aug 5, 2021

but now that we're changing default API behavior it might be a good time to tag this as [api-major] instead and let the next release be version 3.0.

Well, this wouldn't exactly be the first time that we've made backwards incompatible changes in api-minor releases :-)
Hence I'm not sure if this particular patch is all that much worse than a lot of other things we've changed over the years.

The es5 -> legacy renaming is one recent example of something that should probably (technically speaking) not have been done as a minor change, and generally speaking over the years we've done a lot of clean-up/re-factoring of API-methods that in one way or another broke backwards compatibility.

All-in-all, if we're thinking about increasing the major version then (in my opinion) it feels like there should be some substantial new feature(s) included and not just incremental changes. E.g. XFA-support might be one such thing, however that's still under very active development and I'd really like to not hold back the changes in this PR (since they might facilitate things such as issue 7282, assuming we want to fix that).

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Aug 6, 2021

From: Bot.io (Linux m4)


Received

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

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

@pdfjsbot
Copy link

pdfjsbot commented Aug 6, 2021

From: Bot.io (Linux m4)


Success

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

Total script time: 5.10 mins

Published

@timvandermeij timvandermeij merged commit 952f636 into mozilla:master Aug 7, 2021
@timvandermeij
Copy link
Contributor

Thank you for doing this! I can't really argue with #13867 (comment) and the default value is now also what most users are interested in anyway, so let's do this.

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