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

[Form] Don't use field appearances when /NeedAppearances is set to true (bug 1796741) #15615

Merged
merged 1 commit into from
Oct 31, 2022

Conversation

calixteman
Copy link
Contributor

When a form isn't changed, we used the appearances we had in the file, but when /NeedAppearances is true, all the appearances have to be regenerated whatever they're.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented Oct 24, 2022

I can't access the bug, can you please CC me on it so that I have the complete context here?

return null;
})
);
const acroFormPromise = this.pdfManager.ensureCatalog("acroForm");
Copy link
Collaborator

Choose a reason for hiding this comment

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

With the comment above addressed, do we actually need to make any changes in this file?

@@ -1480,6 +1491,10 @@ class WidgetAnnotation extends Annotation {
constructor(params) {
super(params);

if (params.needAppearances) {
this.appearance = null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we break any other code-path, e.g. related to saving or similar, if we simply clear out the this.appearance data here?
Since I don't know the annotation-related code well enough to tell right away, I figured that it couldn't hurt to ask.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normally no.
When the appearance is null, a new one should be generated from the field value..

@@ -138,6 +148,7 @@ class AnnotationFactory {
attachments,
xfaDatasets,
collectFields,
needAppearances,
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Oct 24, 2022

Choose a reason for hiding this comment

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

Given

pdfManager.ensureCatalog("acroForm"),
above, could we not simply do something like the following here instead?

Suggested change
needAppearances,
needAppearances: (acroForm instanceof Dict && acroForm.get("NeedAppearances)) || false,

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

r=me, with passing tests; thank you!

@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @calixteman received. Current queue size: 1

Live output at: http://54.241.84.105:8877/2f856d9e3d7e740/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @calixteman received. Current queue size: 1

Live output at: http://54.193.163.58:8877/ec8896a3056a300/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/2f856d9e3d7e740/output.txt

Total script time: 3.92 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: Passed
  • Regression tests: FAILED

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

@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/cf49613e5a6475b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @calixteman received. Current queue size: 1

Live output at: http://54.193.163.58:8877/af3b00702ab3e94/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/ec8896a3056a300/output.txt

Total script time: 7.17 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Integration Tests: FAILED
  • Regression tests: FAILED

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

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/cf49613e5a6475b/output.txt

Total script time: 24.95 mins

  • Font tests: Passed
  • 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/cf49613e5a6475b/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/af3b00702ab3e94/output.txt

Total script time: 29.97 mins

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

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

@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/d80fe200618527a/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/78fbc63a7b218e9/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/d80fe200618527a/output.txt

Total script time: 24.81 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/78fbc63a7b218e9/output.txt

Total script time: 29.04 mins

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

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

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

Revoking approval, while there's still ref-test regressions.

attachments,
xfaDatasets,
collectFields,
needAppearances:
!collectFields && (acroFormDict.get("NeedAppearances") || false),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that this should be a boolean value, can we please check explicitly for that to prevent any future surprises/bugs in corrupt documents?
For example, what if the entry happens to be a non-empty string or any other truthy value?

Suggested change
!collectFields && (acroFormDict.get("NeedAppearances") || false),
!collectFields && acroFormDict.get("NeedAppearances") === true,

@calixteman
Copy link
Contributor Author

/botio test

@Snuffleupagus
Copy link
Collaborator

It's because of the test itself:

Sorry, but that still doesn't explain why it can be reproduced in the viewer with annotationMode = 1 set!?

@calixteman
Copy link
Contributor Author

It's because of the test itself:

Sorry, but that still doesn't explain why it can be reproduced in the viewer with annotationMode = 1 set!?

Very likely because of:

break;

@Snuffleupagus
Copy link
Collaborator

I still don't at all understand why these changes lead to the double rendering here, and I don't think it's correct to just leave this as-is.

(And this PR now looks way to risky to land less than a week before the next release...)

@calixteman
Copy link
Contributor Author

The annotation is rendered one time in the annotationLayer and a second time in the canvas because the intent parameter in the getOperatorList function doesn't contain the flag RenderingIntentFlag.ANNOTATIONS_FORMS.

@calixteman
Copy link
Contributor Author

calixteman commented Oct 25, 2022

The pdf has the flag /NeedAppearances set to true which means that the appearance for this form field must be generated based on its value, it's why there is something to render.
The stream is null here, so it's why, before the patch, an empty appearance was "rendered" on the canvas.

@calixteman
Copy link
Contributor Author

Maybe the fix is just to add RenderingIntentFlag.ANNOTATIONS_FORMS in the intent when we've an annotation layer.
But I think we should do that in a follow-up.

@Snuffleupagus
Copy link
Collaborator

The annotation is rendered one time in the annotationLayer

Based on a brief look the solution is probably to update the hasAppearance parameter accordingly when /NeedAppearances is set, since that parameter is no longer correct in that case.

Maybe the fix is just to add RenderingIntentFlag.ANNOTATIONS_FORMS in the intent when we've an annotation layer.
But I think we should do that in a follow-up.

No, it must be possible to render annotations without also enabling forms (this was the behaviour for years).

@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/bf7b8f4607e84bf/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/3e9a664a01f42b2/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/bf7b8f4607e84bf/output.txt

Total script time: 25.07 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/3e9a664a01f42b2/output.txt

Total script time: 29.78 mins

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

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

@@ -3020,18 +3036,26 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
return super._getAppearance(evaluator, task, annotationStorage);
}

if (!annotationStorage) {
if (!annotationStorage && this.appearance) {
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Oct 26, 2022

Choose a reason for hiding this comment

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

Won't this cause an error to be thrown below if annotationStorage === undefined and this.appearance === undefined (or this.appearance === null)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you're right, thanks for catching that.
I updated to have something similar to what we have in the appearance getter for text fields.

…ue (bug 1796741)

When a form isn't changed, we used the appearances we had in the file, but when
/NeedAppearances is true, all the appearances have to be regenerated whatever they're.
@calixteman
Copy link
Contributor Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/353591a9847c29b/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/537d5f92a158de0/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/353591a9847c29b/output.txt

Total script time: 25.23 mins

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

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

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/537d5f92a158de0/output.txt

Total script time: 30.48 mins

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

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

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

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

Hopefully we've now fixed all problems here, since the remaining movement in the tests should be expected/improvements.
Given that the double rendering has now been fully understood, and that the fix was pretty simple and straightforward I'm less worried about that.

Your call whether to land this now, or wait until after the upcoming release from the 3-branch.

@calixteman calixteman merged commit e42e1cd into mozilla:master Oct 31, 2022
@calixteman
Copy link
Contributor Author

/botio makeref

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/769f9c638febd8a/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_makeref from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/404000e086d6906/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/769f9c638febd8a/output.txt

Total script time: 21.22 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/404000e086d6906/output.txt

Total script time: 23.23 mins

  • Lint: Passed
  • Make references: Passed
  • Check references: Passed

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

Successfully merging this pull request may close these issues.

3 participants