Improve memory usage around the BasePdfManager.docBaseUrl parameter (PR 7689 follow-up)

While there is nothing *outright* wrong with the existing implementation, it can however lead to increased memory usage in one particular case (that I completely overlooked when implementing this):
For "data:"-URLs, which by definition contains the entire PDF document and can thus be arbitrarily large, we obviously want to avoid sending, storing, and/or logging the "raw" docBaseUrl in that case.

To address this, this patch makes the following changes:
 - Ignore any non-string in the `docBaseUrl` option passed to `getDocument`, since those are unsupported anyway, already on the main-thread.

 - Ignore "data:"-URLs in the `docBaseUrl` option passed to `getDocument`, to avoid having to send what could potentially be a *very* long string to the worker-thread.

 - Parse the `docBaseUrl` option *directly* in the `BasePdfManager`-constructors, on the worker-thread, to avoid having to store the "raw" docBaseUrl in the first place.
This commit is contained in:
Jonas Jenwald 2021-03-16 11:56:39 +01:00
parent bd9dee1544
commit c4c7216171
3 changed files with 26 additions and 18 deletions

View file

@ -708,6 +708,7 @@ export {
DOMSVGFactory,
getFilenameFromUrl,
getPdfFilenameFromUrl,
isDataScheme,
isFetchSupported,
isPdfFile,
isValidFetchUrl,