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:
parent
15d9faba57
commit
c0671ac133
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user