-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Implement streaming using moz-chunk-arraybuffer #5263
Conversation
@@ -903,6 +937,8 @@ PdfStreamConverter.prototype = { | |||
aRequest.contentLength >= 0 && | |||
hash.indexOf('disableRange=true') < 0; | |||
} | |||
var streamRequest = !getBoolPref(PREF_PREFIX + '.disableStream', false) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add this pref to default_preferences.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep
This looks really nice, but I haven't really had time to dig into the code yet! I've done some quick testing and found that for large files, it seems that this patch can significantly increase the time to render the first page in some cases. |
pdf.pdf has issue with the named destination read -- it's too huge for us, so processing of that takes most of the time. We need to file a separate bug for that. (I think the same issue you will have with disalbeRange=true) Another benefit I forgot to mention that, the cache will be used for the next load attempts. |
That is a bit slower on
That's great! |
@yurydelendik |
Thanks |
for performance of pdf.pdf, #5266 is filed |
Math.floor(position / this.chunkSize); | ||
var curChunk; | ||
for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) { | ||
if (!(curChunk in this.loadedChunks)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace this line with if (!this.loadedChunks[curChunk]) {
@@ -903,6 +937,8 @@ PdfStreamConverter.prototype = { | |||
aRequest.contentLength >= 0 && | |||
hash.indexOf('disableRange=true') < 0; | |||
} | |||
var streamRequest = !getBoolPref(PREF_PREFIX + '.disableStream', false) && | |||
hash.indexOf('disableStream=true') < 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If range requests are disabled then hash
won't be defined and thus throw a TypeError
here. Let's move line yurydelendik@87b1298#diff-985966130e4e9f07e74f562c737dee81R934 above the if
block.
Also, this way you can move yurydelendik@87b1298#diff-985966130e4e9f07e74f562c737dee81R938 to line yurydelendik@87b1298#diff-985966130e4e9f07e74f562c737dee81R923 instead (saving a few ops when disableRange === true
).
code looks ok to me. I wonder how often that progress event fires. can one control that? could anyone fire up a preview instance to look at? |
/botio-windows preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/f2a38c22acbe978/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/f2a38c22acbe978/output.txt Total script time: 0.88 mins Published
|
In my chrome 37 on mac os, there is now a significant "lag" until the loading of the pdf starts. the dev tools show that pdf.worker.js is executing. |
Hmmm, this PR shall not affect Chrome since moz-chunk-arraybuffer is not avialable there |
@CodingFabian cache? |
same lag on windows 7. chrome 36 and IE 11. |
@CodingFabian "the pdf" is test/pdfs/pdf.pdf ? see #5266 |
no, just the tracemonkey paper. and in network tab i do not even see it starting for a while |
Looks good here |
hmm. now its gone. could see it on two machines. maybe a server side issue/slowdown? |
107.22.172.223? yes, that's a slow virtual machine |
yeah, all good here, also with range requests disabled |
3087e34
to
f7491bd
Compare
f7491bd
to
07a2539
Compare
Implement streaming using moz-chunk-arraybuffer
Implements #4739 with
moz-chunk-arraybuffer
. Support of the http://www.w3.org/TR/streams-api/ will be easier to add.The PDFJS.disableStream option added to disable this functionality. Currently it autodetects presence of moz-chunk-arraybuffer feature, and if enabled turns on the streaming of the PDF (in addition to range requests). The disableAutoFetch is true when streaming in process.