Skip to content

Commit a80f10f

Browse files
committed
Remove the onProgress callback from the IPDFStreamRangeReader interface
Note how there's *nowhere* in the code-base where the `IPDFStreamRangeReader.prototype.onProgress` callback is actually being set and used, however the loadingBar (in the viewer) still works just fine since loading progress is already reported via: - The `ChunkedStreamManager` instance respectively the `getPdfManager` function, through the use of a "DocProgress" message, on the worker-thread. - A `IPDFStreamReader.prototype.onProgress` callback, on the main-thread. Furthermore, it would definitely *not* be a good idea to add any `IPDFStreamRangeReader.prototype.onProgress` callbacks since they only include the `loaded`-property which would trigger the "indeterminate" loadingBar (in the viewer). Looking briefly at the history of this code it's not clear, at least to me, when this became unused however it's probably close to a decade ago.
1 parent 05b78ce commit a80f10f

File tree

6 files changed

+2
-36
lines changed

6 files changed

+2
-36
lines changed

src/core/worker_stream.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class PDFWorkerStreamReader {
105105
class PDFWorkerStreamRangeReader {
106106
constructor(begin, end, msgHandler) {
107107
this._msgHandler = msgHandler;
108-
this.onProgress = null;
109108

110109
const readableStream = this._msgHandler.sendWithStream("GetRangeReader", {
111110
begin,

src/display/fetch_stream.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ class PDFFetchStreamRangeReader {
205205
constructor(stream, begin, end) {
206206
this._stream = stream;
207207
this._reader = null;
208-
this._loaded = 0;
209208
const source = stream.source;
210209
this._withCredentials = source.withCredentials || false;
211210
this._readCapability = Promise.withResolvers();
@@ -235,8 +234,6 @@ class PDFFetchStreamRangeReader {
235234
this._reader = response.body.getReader();
236235
})
237236
.catch(this._readCapability.reject);
238-
239-
this.onProgress = null;
240237
}
241238

242239
async read() {
@@ -245,9 +242,6 @@ class PDFFetchStreamRangeReader {
245242
if (done) {
246243
return { value, done };
247244
}
248-
this._loaded += value.byteLength;
249-
this.onProgress?.({ loaded: this._loaded });
250-
251245
return { value: getArrayBuffer(value), done: false };
252246
}
253247

src/display/network.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,12 @@ class PDFNetworkStreamRangeRequestReader {
367367
onHeadersReceived: this._onHeadersReceived.bind(this),
368368
onDone: this._onDone.bind(this),
369369
onError: this._onError.bind(this),
370-
onProgress: this._onProgress.bind(this),
370+
onProgress: null,
371371
});
372372
this._requests = [];
373373
this._queuedChunk = null;
374374
this._done = false;
375375
this._storedError = undefined;
376-
377-
this.onProgress = null;
378376
}
379377

380378
_onHeadersReceived() {
@@ -412,10 +410,6 @@ class PDFNetworkStreamRangeRequestReader {
412410
this._queuedChunk = null;
413411
}
414412

415-
_onProgress(evt) {
416-
this.onProgress?.({ loaded: evt.loaded });
417-
}
418-
419413
async read() {
420414
if (this._storedError) {
421415
throw this._storedError;

src/display/node_stream.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ class PDFNodeStreamFsRangeReader {
206206
_reader = null;
207207

208208
constructor(stream, begin, end) {
209-
this.onProgress = null;
210-
this._loaded = 0;
211-
212209
const url = stream.url;
213210
const fs = process.getBuiltinModule("fs");
214211
try {
@@ -232,9 +229,6 @@ class PDFNodeStreamFsRangeReader {
232229
if (done) {
233230
return { value, done };
234231
}
235-
this._loaded += value.length;
236-
this.onProgress?.({ loaded: this._loaded });
237-
238232
return { value: getArrayBuffer(value), done: false };
239233
}
240234

src/display/transport_stream.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ class PDFDataTransportStream {
111111
}
112112

113113
_onProgress(evt) {
114-
if (evt.total === undefined) {
115-
// Reporting to first range reader, if it exists.
116-
this._rangeReaders[0]?.onProgress?.({ loaded: evt.loaded });
117-
} else {
114+
if (evt.total !== undefined) {
118115
this._fullRequestReader?.onProgress?.({
119116
loaded: evt.loaded,
120117
total: evt.total,
@@ -265,8 +262,6 @@ class PDFDataTransportStreamRangeReader {
265262
this._queuedChunk = null;
266263
this._requests = [];
267264
this._done = false;
268-
269-
this.onProgress = null;
270265
}
271266

272267
_enqueue(chunk) {

src/interfaces.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,6 @@ class IPDFStreamReader {
135135
* @interface
136136
*/
137137
class IPDFStreamRangeReader {
138-
constructor() {
139-
/**
140-
* Sets or gets the progress callback. The callback can be useful when the
141-
* isStreamingSupported property of the object is defined as false.
142-
* The callback is called with one parameter: an object with the loaded
143-
* property.
144-
*/
145-
this.onProgress = null;
146-
}
147-
148138
/**
149139
* Requests a chunk of the binary data. The method returns the promise, which
150140
* is resolved into object with properties "value" and "done". If the done

0 commit comments

Comments
 (0)