From 2d3ddc26f545a61ff1e8babb2affb0fabef42bbd Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:25:33 +0100 Subject: [PATCH] web: ship the SBS library's bitmaps beside the wasm, not inside it The SBS library import (#219) embeds every file under assets/sbs into every build, the browser one included. Its resources/ bitmaps are already compressed PNG/EXR/BMP (14.1 MB, deflate saves 1%), and with them the release wasm grew from 14.3 MB to 33.3 MB, past the 24 MiB gate in packaging/web/package.sh that guards Cloudflare Pages' 25 MiB file cap. The nightly Release dry run has failed on Web (wasm) since. For wasm32 the formats build script now leaves resources/ out of the embedded library and lists it as EXTERNAL_ASSETS. index.html copies assets/sbs/resources to sbs/resources in the dist, and the web app downloads those files at startup (in parallel, before the session is created) and hands them to library::install, so library::read serves them as before. A failed download is logged and surfaces as a missing asset on the nodes that use it; startup goes on. Native builds still embed everything. --- Cargo.lock | 1 + apps/materialcraft-web/Cargo.toml | 4 ++- apps/materialcraft-web/index.html | 2 ++ apps/materialcraft-web/src/main.rs | 8 +++++ apps/materialcraft-web/src/web.rs | 37 +++++++++++++++++++++ crates/formats/build.rs | 20 +++++++++-- crates/formats/src/sbs/library.rs | 53 ++++++++++++++++++++++++++++-- packaging/web/README.md | 7 ++-- 8 files changed, 125 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7fb86c6..fb4df87 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2983,6 +2983,7 @@ dependencies = [ "js-sys", "log", "materialcraft-engine", + "materialcraft-formats", "materialcraft-ui-egui", "wasm-bindgen", "wasm-bindgen-futures", diff --git a/apps/materialcraft-web/Cargo.toml b/apps/materialcraft-web/Cargo.toml index e52df34..084eb87 100644 --- a/apps/materialcraft-web/Cargo.toml +++ b/apps/materialcraft-web/Cargo.toml @@ -21,7 +21,9 @@ log = { workspace = true } [target.'cfg(target_arch = "wasm32")'.dependencies] # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "persistence"] } +# The SBS library's `resources/`, which the browser build downloads at startup. +materialcraft-formats = { workspace = true } wasm-bindgen = "0.2" wasm-bindgen-futures = "0.4" js-sys = "0.3" -web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlCanvasElement", "Location", "KeyboardEvent", "EventTarget", "AddEventListenerOptions"] } +web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlCanvasElement", "Location", "KeyboardEvent", "EventTarget", "AddEventListenerOptions", "Response"] } diff --git a/apps/materialcraft-web/index.html b/apps/materialcraft-web/index.html index 9cce260..ddc2176 100644 --- a/apps/materialcraft-web/index.html +++ b/apps/materialcraft-web/index.html @@ -6,6 +6,8 @@