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

Intermittent bug with XFA test on the bots #14014

Closed
calixteman opened this issue Sep 13, 2021 · 6 comments · Fixed by #14240
Closed

Intermittent bug with XFA test on the bots #14014

calixteman opened this issue Sep 13, 2021 · 6 comments · Fixed by #14240

Comments

@calixteman
Copy link
Contributor

calixteman commented Sep 13, 2021

I ran makeref on the linux bot using X11 forwarding and I managed to get a profile when Firefox hung. For information, I found nothing neither in the console nor in the terminal nor in network panel which helped me to guess what was wrong.
I added few console.log to try to figure out where the hang happened and it was during toHTML:

this.pages = this.form[$toHTML]();

and so I finally added a setTimeout(() => console.log(node.constructor.name), 10000) + a clearTimeout around the call to toHTML: https://github.com/mozilla/pdf.js/blob/master/src/core/xfa/xfa_object.js#L370 (and the same around the toHTML in template.js file).
And I ran makeref in a while true during 8 hours and no hang... :(

About the profile, from @gabrielesvelto: "Firefox isn't doing nothing but it's waiting for an event in main event loop".

@calixteman
Copy link
Contributor Author

@Snuffleupagus, @timvandermeij, if you've any idea to try something which could help to figure out what's wrong please propose.

@Snuffleupagus
Copy link
Collaborator

One thing that I've noticed is different between XFA documents and "regular" documents, is that the XFA documents are parsed all once. As far as I understand the data structure of XFA documents basically force this, however I do wonder if this is maybe somehow related to these problems!?

Note how for "regular" documents, during both parsing and rendering (see src/core/evaluator.js and src/display/canvas.js), we'll divide the parsing/rendering into small chunks and repeatedly defer to the event loop to avoid long running parsing/rendering from hanging the browser.

Hence my, possibly dumb, idea: Would it be possible to make the XFA parsing slightly asynchronous, for example by deferring to the event loop after each parsed page?

@marco-c
Copy link
Contributor

marco-c commented Oct 15, 2021

We could try to go back in the history of PRs and try to figure out what was the first change where we hit this failure.

@brendandahl
Copy link
Contributor

Note: the linux bot IP changed during this time, but the logs should still be on the server. new ip 54.241.84.105

@calixteman
Copy link
Contributor Author

I think the first time we saw the problem was in this PR:
#13653

@calixteman
Copy link
Contributor Author

@Snuffleupagus, I don't understand why you could be right but it's definitely something I want to try.
So I think it should be possible to do that in using transforming:

[$toHTML]() {

into a generator function to yield each page which could allow us to delay the conversion for the next page in using a setTimeout. Having a generator function would help to save and restore the state we were before yielding a page.

calixteman added a commit to calixteman/pdf.js that referenced this issue Nov 5, 2021
calixteman added a commit to calixteman/pdf.js that referenced this issue Nov 5, 2021
calixteman added a commit to calixteman/pdf.js that referenced this issue Nov 6, 2021
calixteman added a commit that referenced this issue Nov 6, 2021
XFA - Get each page asynchronously in order to avoid blocking the event loop (#14014)
bh213 pushed a commit to bh213/pdf.js that referenced this issue Jun 3, 2022
rousek pushed a commit to signosoft/pdf.js that referenced this issue Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants