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

[Firefox] Lazy load network.js in PdfStreamConverter.js #4501

Merged
merged 1 commit into from
Mar 25, 2014
Merged

[Firefox] Lazy load network.js in PdfStreamConverter.js #4501

merged 1 commit into from
Mar 25, 2014

Conversation

Snuffleupagus
Copy link
Collaborator

Inspired by this thread, started by @nnethercote on dev.platform: https://groups.google.com/forum/#!topic/mozilla.dev.platform/sAuhWQOAWic.

This PR changes network.js to be lazily loaded instead, to delay loading it until it's needed and to avoid affecting the browser start-up.

I my testing this works fine, and given that we already lazy load other modules (e.g. PdfJsTelemetry.jsm) I don't think that there should be any issues with this change.

@nnethercote
Copy link
Contributor

Nice!

@nnethercote
Copy link
Contributor

While we're here: the other pdf.js compartments seen at start-up:

[System Principal], resource://pdf.js/default_preferences.js
[System Principal], resource://pdf.js/PdfJs.jsm
[System Principal], resource://pdf.js/PdfRedirector.jsm
[System Principal], resource://pdf.js/PdfStreamConverter.jsm

Are they all necessary? If so, could any be combined easily? default_preferences.js is tiny...

@Snuffleupagus
Copy link
Collaborator Author

Are they all necessary?

The way that the code is currently structured, I think most of them are.
PdfJs.jsm is used to register PDF.js as the handler for PDF files, and is invoked by: http://dxr.mozilla.org/mozilla-central/source/browser/components/nsBrowserGlue.js?from=nsBrowserGlue.js (lines #56-57 and #476).

Both PdfStreamConverter.jsm and PdfRedirector.jsm are then (indirectly) loaded by https://github.com/mozilla/pdf.js/blob/master/extensions/firefox/content/PdfJs.jsm#L111 (https://github.com/mozilla/pdf.js/blob/master/extensions/firefox/content/PdfJs.jsm#L244).

If so, could any be combined easily?

I don't know enough about these parts of the code base to answer that, sorry!

default_preferences.js is tiny...

Yes, and I have a patch ready that use the preprocessor to include this code where necessary. However, I wanted to submit this PR first to gauge the interest in these kind of changes before submitting that one.

@Snuffleupagus
Copy link
Collaborator Author

Actually, it seems probable (I haven't tested though) that we could change these to be lazily loaded as well: https://github.com/mozilla/pdf.js/blob/master/extensions/firefox/content/PdfJs.jsm#L37-L38.
But I'm not sure if it would really make a difference, given that they are both needed in PdfJs.init.

Edit: It might actually be worthwhile to change this anyway, since they are currently loaded irrespective of whether PDF.js is active or not.

@yurydelendik
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/b59b9f658a5a0c4/output.txt

yurydelendik added a commit that referenced this pull request Mar 25, 2014
[Firefox] Lazy load network.js in PdfStreamConverter.js
@yurydelendik yurydelendik merged commit dbbe702 into mozilla:master Mar 25, 2014
@yurydelendik
Copy link
Contributor

Thanks

@Snuffleupagus Snuffleupagus deleted the firefox-lazy-load-network branch March 25, 2014 23:35
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