-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Makes PDF data reading Streams API friendly. #6879
Conversation
} | ||
}; | ||
|
||
function PDFNetworkStreamRangeRequest(manager, begin, end) { |
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.
Nit: for consistency with PDFNetworkStreamFullRequestReader
, shouldn't this be named PDFNetworkStreamRangeRequestReader
instead?
Which such a refactor, I'd like to see more unit tests that verifies that the network layer works as intended. That makes it much easier to build upon this interface (e.g. adding support for the streams API). |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/e8254fd4aa4c7cc/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/b9ed08ef04529cc/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/b9ed08ef04529cc/output.txt Total script time: 20.61 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/e8254fd4aa4c7cc/output.txt Total script time: 21.75 mins
|
|
||
function arraysToBytes(arr) { | ||
if (arr.length === 1 && (arr instanceof Uint8Array)) { | ||
return arr[0]; // shortcut |
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.
Why are you returning a 8-bit integer here? Or should arr instanceof
be arr[0] instanceof
?
b83ca0c
to
f73eaad
Compare
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/4db634964845804/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.22.172.223:8877/b9d5ad22a94637b/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/b9d5ad22a94637b/output.txt Total script time: 20.82 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/4db634964845804/output.txt Total script time: 21.57 mins
|
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/4cd3f72a2fbce1b/output.txt Total script time: 14.56 mins
Image differences available at: http://107.21.233.14:8877/4cd3f72a2fbce1b/reftest-analyzer.html#web=eq.log |
/botio-linux test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @yurydelendik received. Current queue size: 0 Live output at: http://107.21.233.14:8877/354031c9f11c02f/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/57a3ffa353c2399/output.txt Total script time: 20.34 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/354031c9f11c02f/output.txt Total script time: 21.80 mins
|
Actually, there is no point on applying function names (it was legacy practice to ensure we are getting proper stack trace reports). IDEs are capable to navigate between code and jsdoc (as well as show pop-up hints). Not sure how can we be more useful here in grep situation, also once we start moving the code to the ES6 we will probably completely abandon this naming conversion in favor of class definition. |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/23904393ada2d2e/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/23904393ada2d2e/output.txt Total script time: 0.81 mins Published |
/botio test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/bda3d85b7158ee5/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/05a169b92a7efb1/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/05a169b92a7efb1/output.txt Total script time: 20.30 mins
|
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/bda3d85b7158ee5/output.txt Total script time: 23.85 mins
Image differences available at: http://107.21.233.14:8877/bda3d85b7158ee5/reftest-analyzer.html#web=eq.log |
/botio-linux test |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/e64f64ef17dec2d/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/e64f64ef17dec2d/output.txt Total script time: 21.85 mins
|
Makes PDF data reading Streams API friendly.
Nice patch! However, it seems that the issue @timvandermeij mentioned on IRC a few days back is still present in the patch that landed, please see http://logs.glob.uno/?c=mozilla%23pdfjs&s=26+Feb+2016&e=26+Feb+2016#c46715. For example, open http://ftp.acc.umu.se/mirror/CTAN/info/lshort/english/lshort.pdf#disableRange=true&disableStream=true and check the browser console (Ctrl+Shift+J):
|
In order to trigger this, both Edit: I should probably have clarified one thing, the PDF file will still load/render correctly in the above cases, it's just that there's a lot of console spew because of the Also, the error message isn't entirely correct since |
As outlined in #6879 (comment), this is not a breaking error. But it'd be nice to get rid of all that console output (caused by the diff --git a/src/core/worker.js b/src/core/worker.js
index c78b52e..4e4446e 100644
--- a/src/core/worker.js
+++ b/src/core/worker.js
@@ -548,8 +548,14 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
if (source.chunkedViewerLoading) {
pdfStream = new PDFWorkerStream(source, handler);
} else {
+//#if (FIREFOX || MOZCENTRAL)
+// pdfManagerCapability.reject(new Error('PDFNetworkStream is ' +
+// 'undefined in the addon/built-in version.'));
+// return pdfManagerCapability.promise;
+//#else
assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
pdfStream = new PDFNetworkStream(data);
+//#endif
}
} catch (ex) {
pdfManagerCapability.reject(ex);
|
Problem that it shall not be called without source.chunkedViewerLoading set in add-on. I'm trying to understand how it's happening. |
It's due to this case https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L512 and we already resolved a promise at https://github.com/mozilla/pdf.js/blob/master/src/core/worker.js#L537 for that (that's why it is working). |
@@ -196,144 +541,113 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { | |||
} catch (ex) { | |||
pdfManagerCapability.reject(ex); | |||
} | |||
return pdfManagerCapability.promise; |
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.
Shall not be removed?
Reverts back un-need change made at #6879.
Adds PDFWorkerStream and PDFNetworkStream with classes that can provide readers (that are compatible with ReadableByteStream, see Streams API).
In the future PDFNetworkStream can be re-written to support Fetch API. The PDFWorkerStream can be refactored to be more lightweight and move most of I/O logic to the main thread.