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

[api-major] Refactor viewer components initialization to reduce their dependency on the global PDFJS object #9479

Merged
merged 10 commits into from
Feb 14, 2018
Merged

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Feb 13, 2018

Since PR #9185 is, at this point in time, the main remaining blocker for PDF.js 2.0, I've tried to split that one up a bit to hopefully be able to move forward here. As indicated in #9185 (comment) this PR will result in a less than ideal intermediate state, but hopefully that's acceptable.

Fixes #4919.
Fixes #9322.

@timvandermeij Sorry to ask, but I'm hoping that you might be willing (time permitting) to review this?

…lity.js` and into a separate file

Unfortunately, as far as I can tell, we still need the ability to adjust certain viewer options depending on the browser environment in PDF.js version `2.0`. However, we should be able to separate this from the general compatibility code in the `src/shared/compatibility.js` file.
This removes the `PDFJS.useOnlyCssZoom` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
This removes the `PDFJS.maxCanvasPixels` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
…`AnnotationLayerBuilder` option

This removes the `PDFJS.imageResourcesPath` dependency from the viewer components and the test-suite, but please note that as a *temporary* solution the default viewer still uses it.
…nkService` options

This removes the `PDFJS.externalLinkTarget`/`PDFJS.externalLinkRel` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
…ferences with a single `textLayerMode` option/preference

Rather than having two different (but connected) options for the textLayer, I think that it makes sense to try and unify this. For example: currently if `disableTextLayer === true`, then the value of `enhanceTextSelection` is simply ignored.

Since PDF.js version `2.0` already won't be backwards compatible in lots of ways, I don't think that we need to worry about migrating existing preferences here.
…assed, via `BaseViewer`/`PDFPageView`, to `PDFPageProxy.render`

Please note that the, pre-existing, viewer preference is already named `enableWebGL`; fixes 4919.
This allows us to remove an otherwise unnecessary `PDFJS` dependency from the `web/genericcom.js` file.
There's no need to expose these properties multiple times, since they're already exported by `src/display/api.js`.
In order to simplify things, the undocumented `enableStats` option was removed and `pdfBug` is now instead used to enabled general debugging *and* page request/rendering stats.
Considering that in the default viewer the `stats` was only used when debugging was also enabled, this simplification (code wise) definitely seem worthwhile to me.
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/b1940c3c6b3e8ce/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/b1940c3c6b3e8ce/output.txt

Total script time: 8.37 mins

Published

@Snuffleupagus Snuffleupagus changed the title [api-major] Refactor viewer components initialization to reduce their dependecy on the global PDFJS object [api-major] Refactor viewer components initialization to reduce their dependency on the global PDFJS object Feb 13, 2018
@acchou acchou mentioned this pull request Feb 13, 2018
4 tasks
Copy link
Contributor

@yurydelendik yurydelendik left a comment

Choose a reason for hiding this comment

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

Sorry for long response. I looked the overall approach and I like it. I did not do any nitpicking, if @timvandermeij agrees/glances too, we can land it. Thank you for the patch.

@timvandermeij
Copy link
Contributor

timvandermeij commented Feb 13, 2018

Really good. I'll take a close look in the coming few days.

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/3d6bbced84e8f27/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

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

Live output at: http://54.215.176.217:8877/493e7f074e246ea/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/493e7f074e246ea/output.txt

Total script time: 24.37 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/3d6bbced84e8f27/output.txt

Total script time: 40.09 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: Passed

@timvandermeij timvandermeij merged commit 538dda1 into mozilla:master Feb 14, 2018
@timvandermeij
Copy link
Contributor

Thank you for improving this! It's quite a bit to review, but I really like how this simplifies things. The subtle improvements for the text layer are also good to have.

@Snuffleupagus Snuffleupagus deleted the refactor-viewer-options branch February 15, 2018 10:31
@Snuffleupagus
Copy link
Collaborator Author

@yurydelendik, @timvandermeij Thank you both for helping review this!

@Rob--W
Copy link
Member

Rob--W commented Feb 16, 2018

I coincidentally came across this change, and I believe that the decision to not migrate preferences is taken too lightly. The Chrome extension allows administrators to control PDF.js via the preferences, and it is important that these identifiers are stable. Even if you don't want to write migration code, I'd appreciate if you ping me whenever there is a backwards-incompatible preference change. This is also necessary so I can mention the new preference name in release notes.

This is the second time that I notice breaking changes to preferences. For the previous one (hand tool -> hand+cursor tool), I wrote this migration code: 19549bb (similar logic needs to be applied here).
@Snuffleupagus Do you want to write migration code for your change here, or should I do it?

@Snuffleupagus
Copy link
Collaborator Author

[...] and I believe that the decision to not migrate preferences is taken too lightly.

Generally I'd agree that we should always try to migrate preferences, however I think there's extenuating circumstances in this case!
Given that these changes will be release with PDF.js 2.0, which is an increase in the major version number, backwards incompatible changes ought to be allowed/expected. Otherwise, as far as I'm concerned, there doesn't seem to be much reason to increase the major version number.
Furthermore, please note that a number of backwards incompatible API changes have already been made, and there's more to come as well; see https://github.com/mozilla/pdf.js/projects/5.

I'd appreciate if you ping me whenever there is a backwards-incompatible preference change. This is also necessary so I can mention the new preference name in release notes.

That's a fair point, sorry about that!

Do you want to write migration code for your change here, or should I do it?

Unfortunately I don't have time, and my sole focus right now is to get https://github.com/mozilla/pdf.js/projects/5 over the line to avoid holding up future releases any longer.
Also, as indicated above, I'm not totally convinced that migrating is necessary here.

@Rob--W
Copy link
Member

Rob--W commented Feb 16, 2018

The Chrome extension is built off master, so it's already using 2.x.
As the maintainer of the Chrome extension, internal API changes are not really that significant. What matters is the external, user-facing changes, such as preferences.

I'll create a new issue and assign it to me.

@Rob--W
Copy link
Member

Rob--W commented Feb 16, 2018

Eventually these changes will also make it into Firefox, won't it? Firefox is also already using 2.x, shouldn't these preferences be migrated in Firefox too?

@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Feb 16, 2018

Eventually these changes will also make it into Firefox, won't it?

That's correct.

Firefox is also already using 2.x, shouldn't these preferences be migrated in Firefox too?

Considering that the preferences are not easily accessible in the UI, but rather only available through about:config, I wouldn't worry too much about it since nothing will outright "break" here.
Assuming that a user manually set disableTextLayer, the worst thing that will happen is that the text is now selectable/searchable again. As for enhanceTextSelection, that is/was still somewhat experimental and consequently I wouldn't worry about it.

PalmerAL added a commit to minbrowser/min that referenced this pull request Mar 19, 2018
mozilla/pdf.js#9479 broke the PDF viewer, so keep using the older
version until we fix the compatibility issues
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
…tions

[api-major] Refactor viewer components initialization to reduce their dependency on the global `PDFJS` object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants