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

Do not run cleanup while printing is ongoing. #5001

Merged
merged 1 commit into from
Jun 25, 2014

Conversation

CodingFabian
Copy link
Contributor

During investigation of #4994 it became clear that one possible problem with fonts in print is that while printing is ongoing a font is removed and reloaded. If cleanup was set to a low number the problem disappeared.

the cleanup was scheduled when no page or thumbnail was rendered. Because printing uses a different mechanism, t could happen that printing occurs at the same time as cleanup. This is consistent with the observation that the error was reproducible after a few tries (most likely just hitting the 30 second mark).

The solution is to not run cleanup while printing is ongoing. Therefor a flag is set and renderHighestPriority() invoked before and after printing.

@CodingFabian
Copy link
Contributor Author

@yurydelendik @Snuffleupagus as discussed in irc.
it indeed fixes the problem i as able to reproduce. and i assume that it is the problem reported in #4994

PDFView.idleTimeout = setTimeout(function () {
PDFView.cleanup();
}, CLEANUP_TIMEOUT);
},

cleanup: function pdfViewCleanup() {
PDFView.idleTimeout = null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this line, otherwise timer will not be canceled by renderHighestPriority()

@Snuffleupagus
Copy link
Collaborator

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/8eab0ecb7bc84ca/output.txt

@@ -1570,6 +1576,8 @@ var PDFView = {
for (i = 0, ii = this.pages.length; i < ii; ++i) {
this.pages[i].beforePrint();
}
this.printing = true;
this.renderHighestPriority();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these lines perhaps be placed before the loop, to make absolutely sure that the cleanup doesn't run before we have called beforePrint for all pages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know, if you think thats better I can move it, then I will also move the code in after print down to have symmetry.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason that I asked is that I'm not sure exactly how the event loop in JavaScript handles this case. I'm wondering if it's possible that a previously set idleTimeout could be allowed to run before the entire loop has completed (thus causing issues)?
@yurydelendik Is this something that we should be concerned about here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well widening the lock should not be a problem. if we have any doubt we should do it. ill update the pr

yurydelendik added a commit that referenced this pull request Jun 25, 2014
Do not run cleanup while printing is ongoing.
@yurydelendik yurydelendik merged commit 2e98f90 into mozilla:master Jun 25, 2014
@yurydelendik
Copy link
Contributor

Looks good. Thank you for looking into that. I think it will fix some of the printing bugs at bugzilla as well

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

Successfully merging this pull request may close these issues.

4 participants