Slightly increase the maximum image sizes that we'll cache

The current value originated in PR 2317, and in the decade that have passed the amount of RAM available in (most) devices should have increased a fair bit.
Nowadays we also do a much better job of detecting repeated images at both the page- and document-level, which helps reduce overall memory-usage in many documents.

Finally the constant is also moved into the `src/shared/util.js` file, since it was implicitly used on both the main- and worker-thread previously.
This commit is contained in:
Jonas Jenwald 2023-03-04 11:22:59 +01:00
parent 15d9faba57
commit c0671ac133
3 changed files with 13 additions and 4 deletions

View file

@ -26,6 +26,7 @@ import {
info,
InvalidPDFException,
isArrayBuffer,
MAX_IMAGE_SIZE_TO_CACHE,
MissingPDFException,
PasswordException,
RenderingIntentFlag,
@ -2811,7 +2812,6 @@ class WorkerTransport {
pageProxy.objs.resolve(id, imageData);
// Heuristic that will allow us not to store large data.
const MAX_IMAGE_SIZE_TO_STORE = 8000000;
if (imageData) {
let length;
if (imageData.bitmap) {
@ -2821,7 +2821,7 @@ class WorkerTransport {
length = imageData.data?.length || 0;
}
if (length > MAX_IMAGE_SIZE_TO_STORE) {
if (length > MAX_IMAGE_SIZE_TO_CACHE) {
pageProxy._maybeCleanupAfterRender = true;
}
}