Skip to content

Ensure that the viewer handles BaseViewer initialization failures #14345

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

Conversation

Snuffleupagus
Copy link
Collaborator

This patch can be tested e.g. with the poppler-85140-0.pdf document from the test-suite.

For some sufficiently corrupt documents the getDocument call will succeed, but fetching even the very first page fails. Currently we only print error messages (in the console) from the {BaseViewer, PDFThumbnailViewer}.setDocument methods, but don't actually provide these errors to allow the viewer to handle them properly.
In practice this means that the GENERIC viewer won't display the errorWrapper, and in the MOZCENTRAL viewer the browser loading indicator is never hidden (since we never unblock the "load" event).

*This patch can be tested e.g. with the `poppler-85140-0.pdf` document from the test-suite.*

For some sufficiently corrupt documents the `getDocument` call will succeed, but fetching even the very first page fails. Currently we only print error messages (in the console) from the `{BaseViewer, PDFThumbnailViewer}.setDocument` methods, but don't actually provide these errors to allow the viewer to handle them properly.
In practice this means that the GENERIC viewer won't display the `errorWrapper`, and in the MOZCENTRAL viewer the *browser* loading indicator is never hidden (since we never unblock the "load" event).
These changes improves the consistency ever so slightly in the `PDFOutlineViewer._dispatchEvent` method, by making sure that we can tell the following two cases apart:
 - The "pagesloaded" event has *not yet* been fired.
 - The "pagesloaded" event has been fired, but no pages were available.
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Dec 5, 2021

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/4594d98590a7fe4/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Dec 5, 2021

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/4594d98590a7fe4/output.txt

Total script time: 4.34 mins

Published

@timvandermeij timvandermeij merged commit 3264d72 into mozilla:master Dec 5, 2021
@timvandermeij
Copy link
Contributor

Looks good!

@Snuffleupagus Snuffleupagus deleted the viewer-pagesPromise-reject branch December 5, 2021 15:36
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