mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-27 19:27:21 -06:00
fix(format): cap a compressed file's JSON at 256 MB on wasm32 (#3587)
MAX_JSON was 1 GiB on every target, but on wasm32 the 4 GiB address space also holds the document the JSON deserializes into, several times its size. The cap is now a quarter of the native one there, mirroring MAX_BLOBS, and Unpacked::within makes the cap exercisable wherever a test runs. Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
This commit is contained in:
committed by
bflatastic
co-authored by
rahul05ranjan
parent
eb0e99a553
commit
10dfb8b261
@@ -66,8 +66,10 @@ pub const EXTENSION: &str = "vectorcraft";
|
||||
pub const LEGACY_EXTENSION: &str = "drawcraft";
|
||||
/// Most bytes the JSON of a compressed file may unpack to (a guard against decompression bombs,
|
||||
/// as are [`MAX_BLOB`] and [`MAX_BLOBS`]). A compressed save refuses a document past any of them,
|
||||
/// so every file VectorCraft writes reads back.
|
||||
pub const MAX_JSON: u64 = 1 << 30;
|
||||
/// so every file VectorCraft writes reads back. On wasm32 the cap is a quarter of the native
|
||||
/// one: the JSON is deserialized into a document several times its size, and the 4 GiB address
|
||||
/// space also holds the file, the JSON, the document and the app (#3587).
|
||||
pub const MAX_JSON: u64 = if cfg!(target_arch = "wasm32") { 256 << 20 } else { 1 << 30 };
|
||||
/// Most bytes one entry of the data after the JSON (an image, a placed document, the PDF, a
|
||||
/// profile) may have in a compressed file.
|
||||
pub const MAX_BLOB: u64 = 1 << 30;
|
||||
|
||||
Reference in New Issue
Block a user