diff --git a/src/core/image_utils.js b/src/core/image_utils.js index 8cef91dc0..1dfb5b740 100644 --- a/src/core/image_utils.js +++ b/src/core/image_utils.js @@ -13,7 +13,13 @@ * limitations under the License. */ -import { assert, shadow, unreachable, warn } from "../shared/util.js"; +import { + assert, + MAX_IMAGE_SIZE_TO_CACHE, + shadow, + unreachable, + warn, +} from "../shared/util.js"; import { RefSetCache } from "./primitives.js"; class BaseLocalCache { @@ -160,7 +166,7 @@ class GlobalImageCache { } static get MAX_BYTE_SIZE() { - return shadow(this, "MAX_BYTE_SIZE", /* Forty megabytes = */ 40e6); + return shadow(this, "MAX_BYTE_SIZE", 5 * MAX_IMAGE_SIZE_TO_CACHE); } constructor() { diff --git a/src/display/api.js b/src/display/api.js index e44dd78ba..00adb9044 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -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; } } diff --git a/src/shared/util.js b/src/shared/util.js index d500aa9a7..873e26e0c 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -26,6 +26,8 @@ if ( const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; +const MAX_IMAGE_SIZE_TO_CACHE = 10e6; // Ten megabytes. + // Represent the percentage of the height of a single-line field over // the font size. Acrobat seems to use this value. const LINE_FACTOR = 1.35; @@ -1060,6 +1062,7 @@ export { isArrayEqual, LINE_DESCENT_FACTOR, LINE_FACTOR, + MAX_IMAGE_SIZE_TO_CACHE, MissingPDFException, objectFromMap, objectSize,