mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Stop using the source
-object when sending "GetDocRequest"
Looking at the code on the worker-thread, there doesn't appear to be any particular reason for placing *some* of the properties in a `source`-object when sending them with "GetDocRequest". As is often the case the explanation for this structure is rather "for historical reasons", since originally we simply sent the `source`-object as-is. Doing that was obviously a bad idea, for a couple of reasons: - It makes it less clear what is/isn't actually needed on the worker-thread. - Sending unused properties will unnecessarily increase memory usage. - The `source`-object may contain unclonable data, which would break the library.
This commit is contained in:
parent
c84b717773
commit
8a4f6aca97
2 changed files with 29 additions and 26 deletions
|
@ -503,20 +503,18 @@ async function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||
}
|
||||
const workerId = await worker.messageHandler.sendWithPromise(
|
||||
"GetDocRequest",
|
||||
// Only send the required properties, and *not* the entire `source` object.
|
||||
{
|
||||
docId,
|
||||
apiVersion:
|
||||
typeof PDFJSDev !== "undefined" && !PDFJSDev.test("TESTING")
|
||||
? PDFJSDev.eval("BUNDLE_VERSION")
|
||||
: null,
|
||||
// Only send the required properties, and *not* the entire object.
|
||||
source: {
|
||||
data: source.data,
|
||||
password: source.password,
|
||||
disableAutoFetch: source.disableAutoFetch,
|
||||
rangeChunkSize: source.rangeChunkSize,
|
||||
length: source.length,
|
||||
},
|
||||
data: source.data,
|
||||
password: source.password,
|
||||
disableAutoFetch: source.disableAutoFetch,
|
||||
rangeChunkSize: source.rangeChunkSize,
|
||||
length: source.length,
|
||||
docBaseUrl: source.docBaseUrl,
|
||||
enableXfa: source.enableXfa,
|
||||
evaluatorOptions: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue