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.
This commit is contained in:
Jonas Jenwald 2026-01-30 07:56:22 +01:00
parent 05b78ce03c
commit a80f10ff1a
6 changed files with 2 additions and 36 deletions

View File

@ -105,7 +105,6 @@ class PDFWorkerStreamReader {
class PDFWorkerStreamRangeReader {
constructor(begin, end, msgHandler) {
this._msgHandler = msgHandler;
this.onProgress = null;
const readableStream = this._msgHandler.sendWithStream("GetRangeReader", {
begin,

View File

@ -205,7 +205,6 @@ class PDFFetchStreamRangeReader {
constructor(stream, begin, end) {
this._stream = stream;
this._reader = null;
this._loaded = 0;
const source = stream.source;
this._withCredentials = source.withCredentials || false;
this._readCapability = Promise.withResolvers();
@ -235,8 +234,6 @@ class PDFFetchStreamRangeReader {
this._reader = response.body.getReader();
})
.catch(this._readCapability.reject);
this.onProgress = null;
}
async read() {
@ -245,9 +242,6 @@ class PDFFetchStreamRangeReader {
if (done) {
return { value, done };
}
this._loaded += value.byteLength;
this.onProgress?.({ loaded: this._loaded });
return { value: getArrayBuffer(value), done: false };
}

View File

@ -367,14 +367,12 @@ class PDFNetworkStreamRangeRequestReader {
onHeadersReceived: this._onHeadersReceived.bind(this),
onDone: this._onDone.bind(this),
onError: this._onError.bind(this),
onProgress: this._onProgress.bind(this),
onProgress: null,
});
this._requests = [];
this._queuedChunk = null;
this._done = false;
this._storedError = undefined;
this.onProgress = null;
}
_onHeadersReceived() {
@ -412,10 +410,6 @@ class PDFNetworkStreamRangeRequestReader {
this._queuedChunk = null;
}
_onProgress(evt) {
this.onProgress?.({ loaded: evt.loaded });
}
async read() {
if (this._storedError) {
throw this._storedError;

View File

@ -206,9 +206,6 @@ class PDFNodeStreamFsRangeReader {
_reader = null;
constructor(stream, begin, end) {
this.onProgress = null;
this._loaded = 0;
const url = stream.url;
const fs = process.getBuiltinModule("fs");
try {
@ -232,9 +229,6 @@ class PDFNodeStreamFsRangeReader {
if (done) {
return { value, done };
}
this._loaded += value.length;
this.onProgress?.({ loaded: this._loaded });
return { value: getArrayBuffer(value), done: false };
}

View File

@ -111,10 +111,7 @@ class PDFDataTransportStream {
}
_onProgress(evt) {
if (evt.total === undefined) {
// Reporting to first range reader, if it exists.
this._rangeReaders[0]?.onProgress?.({ loaded: evt.loaded });
} else {
if (evt.total !== undefined) {
this._fullRequestReader?.onProgress?.({
loaded: evt.loaded,
total: evt.total,
@ -265,8 +262,6 @@ class PDFDataTransportStreamRangeReader {
this._queuedChunk = null;
this._requests = [];
this._done = false;
this.onProgress = null;
}
_enqueue(chunk) {

View File

@ -135,16 +135,6 @@ class IPDFStreamReader {
* @interface
*/
class IPDFStreamRangeReader {
constructor() {
/**
* Sets or gets the progress callback. The callback can be useful when the
* isStreamingSupported property of the object is defined as false.
* The callback is called with one parameter: an object with the loaded
* property.
*/
this.onProgress = null;
}
/**
* Requests a chunk of the binary data. The method returns the promise, which
* is resolved into object with properties "value" and "done". If the done