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

feat(viewer): Upgrade pdf.js to latest for modern browsers #1441

Merged
merged 7 commits into from
Jul 7, 2022

Conversation

jstoffan
Copy link
Collaborator

@jstoffan jstoffan commented Dec 23, 2021

Huge thanks to @karelee7 for testing and validating these changes:

  • Tested on IE11
  • Tested on Chrome
  • Tested on Firefox
  • Tested on Safari
  • Tested with large PDF files

@jstoffan jstoffan force-pushed the upgrade-pdfjs-modern branch 2 times, most recently from 984b956 to 722ef51 Compare December 23, 2021 20:55

cy.visit('/', {
onBeforeLoad(win) {
// Workaround for fetch detection in cypress mocking. https://github.com/cypress-io/cypress/issues/95
delete win.fetch; // eslint-disable-line no-param-reassign
cy.stub(win, 'fetch').resolves({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I confirmed this change still triggers the expected error both on this branch and on master.

Copy link
Contributor

@ConradJChan ConradJChan left a comment

Choose a reason for hiding this comment

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

I think this is a good approach to help us move forward in the near term and pull in fixes for PDFjs while hanging onto IE support. Do we need to consider any type of feature flip type option to turn this on and off?

src/lib/viewers/doc/DocBaseViewer.js Show resolved Hide resolved
src/lib/viewers/doc/DocBaseViewer.js Show resolved Hide resolved
@jstoffan
Copy link
Collaborator Author

jstoffan commented Jan 6, 2022

I wouldn't bother with a feature flip, since it's essentially the same process to roll back to a prior version of the SDK.

@jstoffan jstoffan force-pushed the upgrade-pdfjs-modern branch 2 times, most recently from 743c108 to ddc8ca5 Compare June 23, 2022 17:51
@jstoffan jstoffan marked this pull request as ready for review June 23, 2022 17:53
@jstoffan jstoffan requested a review from a team as a code owner June 23, 2022 17:53
@jstoffan
Copy link
Collaborator Author

@karelee7, seeing lots of new end-to-end test failures. Does Find work? Presentations?

@karelee7
Copy link
Contributor

karelee7 commented Jun 23, 2022

@jstoffan Ahh lemme see...so for find, it looks like it's having trouble and for presentations, they are either really slow or the file preview doesn't load :( Update! I figured it out with help from Conrad, will update commit now!

src/lib/viewers/doc/DocFindBar.js Outdated Show resolved Hide resolved
src/lib/viewers/doc/DocFindBar.js Outdated Show resolved Hide resolved
src/lib/viewers/doc/PresentationViewer.js Outdated Show resolved Hide resolved
build/upgrade_pdfjs.sh Show resolved Hide resolved
Copy link
Collaborator Author

@jstoffan jstoffan left a comment

Choose a reason for hiding this comment

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

I'm seeing the following error for all PDFs with this patchset:

Cannot read properties of undefined (reading 'EventBus')

src/third-party/doc/2.84.0/pdf_viewer.min.js Outdated Show resolved Hide resolved
build/upgrade_pdfjs.sh Show resolved Hide resolved
@karelee7
Copy link
Contributor

karelee7 commented Jul 1, 2022

Talked with Conrad, we may need to use google compiler + the legacy build of pdfjs for now, and then circle back to babel + the non-legacy build. But I'm going to dig a bit more tonight and tomorrow to see if I can get it to work, if not, then we'll go the google compiler + legacy route for now

@jstoffan
Copy link
Collaborator Author

jstoffan commented Jul 5, 2022

@karelee7, we're making progress, but I found a couple issues while spot-checking:

  • Find next / previous buttons are not functional
  • Highlight and Comment tooltip is mispositioned (see below)

highlight-comment

@karelee7
Copy link
Contributor

karelee7 commented Jul 6, 2022

@jstoffan The fix for find next/prev buttons is in already and as you saw, the tooltip fix was here: box/box-annotations#696 and has been merged in :)

@jstoffan
Copy link
Collaborator Author

jstoffan commented Jul 7, 2022

@ConradJChan will need to review, as I can't approve a PR I opened.

@karelee7 karelee7 requested a review from ConradJChan July 7, 2022 21:41
Copy link
Contributor

@ConradJChan ConradJChan left a comment

Choose a reason for hiding this comment

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

lgtm, great job!

@karelee7 karelee7 merged commit 18eed4f into box:master Jul 7, 2022
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.

None yet

3 participants