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

Remove the disableCreateObjectURL option from web/app_options.js #12191

Conversation

Snuffleupagus
Copy link
Collaborator

Prior to PR #11601, the disableCreateObjectURL option was present on getDocument in the API, since it was (potentially) used when decoding JPEG images natively in the browser. Hence setting this option, which was done automatically using compatibility-code, were in some browsers necessary in order for e.g. JPEG images to be correctly rendered.

The downside of the disableCreateObjectURL option is that memory usage increases significantly, since we're forced to build and use data: URIs (rather than blob: URLs).
However, at this point in time the disableCreateObjectURL option is only necessary for some (non-essential) functionality in the default viewer; in particular:

  • The openfile functionality, used only when manually opening a new file in the default viewer.
  • The download functionality, used when downloading either the PDF document itself or its attached files (if such exists).
  • The print functionality, in the generic PDFPrintService implementation.

Hence neither the general PDF.js library, nor the basic functionality of the default viewer, depends on the disableCreateObjectURL option any more; which is why I'm thus proposing that we remove the option since using it is a performance footgun.

Please note: To not outright break currently "supported" browsers, which lack proper URL.createObjectURL support, this patch purposely keeps the compatibility-code to explicitly disable URL.createObjectURL usage only for browsers which are known to not work correctly.[1]

While it's certainly possible that there's additional, likely older, browsers with broken URL.createObjectURL support, the last time that these types of problems were reported was over three years ago.[2]
Hence in the very unlikely event that additional problems occur, as a result of these changes, we can either add a new case in the compatibility-code or simply declare the affected browser as unsupported.


[1] Which are IE11 (see issue #3977), and Google Chrome on iOS (see PR #8081).

[2] Given that URL.createObjectURL is used by default, you'd really expect more reports if these problems were widespread.

Prior to PR 11601, the `disableCreateObjectURL` option was present on `getDocument` in the API, since it was (potentially) used when decoding JPEG images natively in the browser. Hence setting this option, which was done automatically using compatibility-code, were in some browsers necessary in order for e.g. JPEG images to be correctly rendered.

The downside of the `disableCreateObjectURL` option is that memory usage increases significantly, since we're forced to build and use `data:` URIs (rather than `blob:` URLs).
However, at this point in time the `disableCreateObjectURL` option is only necessary for *some* (non-essential) functionality in the default viewer; in particular:
 - The openfile functionality, used only when manually opening a new file in the default viewer.
 - The download functionality, used when downloading either the PDF document itself or its attached files (if such exists).
 - The print functionality, in the generic `PDFPrintService` implementation.

Hence neither the general PDF.js library, nor the *basic* functionality of the default viewer, depends on the `disableCreateObjectURL` option any more; which is why I'm thus proposing that we remove the option since using it is a performance footgun.

*Please note:* To not outright break currently "supported" browsers, which lack proper `URL.createObjectURL` support, this patch purposely keeps the compatibility-code to explicitly disable `URL.createObjectURL` usage *only* for browsers which are known to not work correctly.[1]

While it's certainly possible that there's additional, likely older, browsers with broken `URL.createObjectURL` support, the last time that these types of problems were reported was over *three* years ago.[2]
Hence in the *very* unlikely event that additional problems occur, as a result of these changes, we can either add a new case in the compatibility-code or simply declare the affected browser as unsupported.

---
[1] Which are IE11 (see issue 3977), and Google Chrome on iOS (see PR 8081).

[2] Given that `URL.createObjectURL` is used by default, you'd really expect more reports if these problems were widespread.
@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/0a9e84f5094aaf4/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/0a9e84f5094aaf4/output.txt

Total script time: 3.34 mins

Published

@timvandermeij timvandermeij merged commit 3380f2a into mozilla:master Aug 11, 2020
@timvandermeij
Copy link
Contributor

I agree with the points that you mentioned. Thanks!

@Snuffleupagus Snuffleupagus deleted the rm-AppOptions-disableCreateObjectURL branch August 12, 2020 07:47
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.

3 participants