From 7bd496b1e2a77096c63cf534307a1ac2686d3756 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Fri, 9 Oct 2026 11:43:59 +0700 Subject: [PATCH] Images: the web app keeps the decoder's 512 MB limit #677 lets one image decode take up to 2 GB, so large print sheets open on the desktop. wasm32 can address only 4 GB and aborts when an allocation fails, so the web app keeps the decoder's default 512 MB and reports larger images as an error instead. Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/fileio/load.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/fileio/load.rs b/crates/engine/src/cmd/fileio/load.rs index 07024fa8..cb681091 100644 --- a/crates/engine/src/cmd/fileio/load.rs +++ b/crates/engine/src/cmd/fileio/load.rs @@ -283,8 +283,9 @@ pub(super) fn new_from_template(s: &mut Session, p: &Value) -> Result { } /// The most memory decoding one image may take: a 60 in print sheet at 300 ppi (18000 × 6600 px) -/// is ~475 MB as RGBA, past the decoder's 512 MB default once it is converted. -const MAX_RASTER_ALLOC: u64 = 2 << 30; +/// is ~475 MB as RGBA, past the decoder's 512 MB default once it is converted. The web app keeps +/// that default: wasm32 has 4 GB to address and aborts when an allocation fails. +const MAX_RASTER_ALLOC: u64 = if cfg!(target_arch = "wasm32") { 512 << 20 } else { 2 << 30 }; /// Decode an image's header (and, for formats stored as PNG, its pixels). CMYK TIFFs are kept as /// they are, with their ink amounts ([`ImageBlob::cmyk`]); CMYK TIFFs with an alpha channel, which