'PDFJS: Get some unnecessary chunks with range request and make first page slow
Configuration:
- Web browser and its version: Chrome 97.0.4692.99
- Operating system and its version: MacOS 10.15.5
- PDF.js version: 2.12.313
- Is a browser extension: no
- I use the range request to render pdf
- I get more chunks with this line of code
await this.pdfManager.requestRange(ex.begin, ex.end);; - These chunks are unnecessary when rendering first page;
- The program also seems to run fine when I comment this line of code, and I can get less chunks to make the first page faster;
- So what does this part of the code do?
- Is it possible not to execute it or not to use await?
// src/core/xref.js
async fetchAsync(ref, suppressEncryption) {
try {
return this.fetch(ref, suppressEncryption);
} catch (ex) {
if (!(ex instanceof MissingDataException)) {
throw ex;
}
await this.pdfManager.requestRange(ex.begin, ex.end);
return this.fetchAsync(ref, suppressEncryption);
}
}
I can get less chunks when I comment this line of code and the program also seems to run fine

If I do nothing,the range request in network like this

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
