1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[Firefox regression] Fix disableRange=true bug in PDFDataTransportStream

Currently if trying to set `disableRange=true` in the built-in PDF Viewer in Firefox, either through `about:config` or via the URL hash, the PDF document will never load. It appears that this has been broken for a couple of years, without anyone noticing.

Obviously it's not a good idea to set `disableRange=true`, however it seems that this bug affects the PDF Viewer in Firefox even with default settings:
 - In the case where `initialData` already contains the *entire* file, we're forced to dispatch a range request to re-fetch already available data just so that file loading may complete.
 - (In the case where the data arrives, via streaming, before being specifically requested through `requestDataRange`, we're also forced to re-fetch data unnecessarily.) *This part was removed, to reduce the scope/risk of the patch somewhat.*

In the cases outlined above, we're having to re-fetch already available data thus potentially delaying loading/rendering of PDF files in Firefox (and wasting resources in the process).
This commit is contained in:
Jonas Jenwald 2019-03-26 16:05:30 +01:00
parent 9b5a937f78
commit bb384dd5ed
4 changed files with 74 additions and 6 deletions

View file

@ -256,7 +256,7 @@ PDFViewerApplication.externalServices = {
switch (args.pdfjsLoadAction) {
case 'supportsRangedLoading':
pdfDataRangeTransport =
new FirefoxComDataRangeTransport(args.length, args.data);
new FirefoxComDataRangeTransport(args.length, args.data, args.done);
callbacks.onOpenWithTransport(args.pdfUrl, args.length,
pdfDataRangeTransport);
@ -270,6 +270,11 @@ PDFViewerApplication.externalServices = {
case 'progressiveRead':
pdfDataRangeTransport.onDataProgressiveRead(args.chunk);
break;
case 'progressiveDone':
if (pdfDataRangeTransport) {
pdfDataRangeTransport.onDataProgressiveDone();
}
break;
case 'progress':
callbacks.onProgress(args.loaded, args.total);
break;