PhotoCraft: An open-source, photo editor written by scratch in pure Rust
UI.9: keep browser bundle under size budget on current main
skylar taylor-barrickd0a18cfd8397
diff --cc Cargo.lockindex 780c4ebdb,311a6103e..fde4ac01b--- a/Cargo.lock+++ b/Cargo.lock@@@ -4563,10 -4554,9 +4563,10 @@@ dependencies =[[package]]name = "photocraft-ui-egui"- version = "0.6.0"+ version = "0.7.0"dependencies = ["base64",+ "craft-ui","eframe","egui","egui_extras",diff --cc Cargo.tomlindex 5d394d3e8,71e68de74..7502ff4fd--- a/Cargo.toml+++ b/Cargo.toml@@@ -81,11 -80,11 +81,10 @@@ codegen-units =# The browser build (apps/photocraft-web, `data-cargo-profile` in its index.html). Hosts cap the# size of a single file (Cloudflare Pages/Workers: 25 MiB), and the wasm is downloaded on every--# visit, so this profile optimizes for size: fat LTO, and opt-level "s" for everything except the--# pixel-processing crates, which keep opt-level 3 so filters and compositing stay fast. panic++# visit, so this profile optimizes for size: fat LTO, opt-level "z" for the UI shell, and "s" for++# other crates except pixel processing, which keeps opt-level 3 for filters and compositing. panic# stays the target default (wasm32-unknown-unknown aborts; AGENTS.md's `panic = "unwind"` is for--# the native app shell). packaging/web/package.sh fails the build above 24 MiB. Issue #198:--# this took the wasm from 26.3 MiB (release profile) to 18.8 MiB.++# the native app shell). packaging/web/package.sh fails the build above 24 MiB.[profile.wasm-release]inherits = "release"opt-level = "s"@@@ -96,6 -95,6 +95,11 @@@ strip = "debuginfo[profile.wasm-release.package."*"]opt-level = "s"++# Keep the browser shell compact as shared panel controls grow. Pixel-processing crates below++# retain their speed-oriented optimization level.++[profile.wasm-release.package.photocraft-ui-egui]++opt-level = "z"++[profile.wasm-release.package.photocraft-raster]opt-level = 3[profile.wasm-release.package.photocraft-color]diff --cc docs/development.mdindex e75aad769,e75aad769..dce0fa35a--- a/docs/development.md+++ b/docs/development.md@@@ -351,7 -351,7 +351,7 @@@ trunk build --release # wrtrunk serve --release # dev server on http://127.0.0.1:8765```--Any static file server works for `dist/web`, for example `python3 -m http.server 8765` run inside that directory. Trunk downloads the matching `wasm-bindgen` and `wasm-opt` itself. `trunk build --release` uses the `wasm-release` Cargo profile (`data-cargo-profile` in `index.html`: fat LTO, opt-level "s" except the pixel crates). The `.wasm` is about 18.8 MiB raw, 7.8 MiB gzipped and 5.6 MiB with Brotli; serve it with compression. Keep it under 24 MiB (`packaging/web/package.sh` enforces this; Cloudflare's per-file cap is 25 MiB). Pull-request CI also builds the actual browser app with the same pinned Trunk version as the release job and runs `packaging/web/package.sh`, including the relative-URL and 24 MiB checks. The `web build and wasm size gate` check runs on main and on PRs that change something the web build compiles or packages (`apps/photocraft-web`, `packaging/web`, crate sources and manifests, `Cargo.toml`/`Cargo.lock`, the CI workflow), and reports the resulting wasm size in the Actions job summary. The web build never embeds craft-fonts (see Fonts above). To see where the bytes go, run `twiggy top -n 40` on `target/wasm32-unknown-unknown/wasm-release/photocraft-web.wasm` (before wasm-opt strips the names).++Any static file server works for `dist/web`, for example `python3 -m http.server 8765` run inside that directory. Trunk downloads the matching `wasm-bindgen` and `wasm-opt` itself. `trunk build --release` uses the `wasm-release` Cargo profile (`data-cargo-profile` in `index.html`: fat LTO, opt-level "z" for `photocraft-ui-egui`, "s" for other crates except pixel processing, which keeps level 3). The UI override reduces browser code size while retaining the speed-oriented settings for filters and compositing. Serve the `.wasm` with compression; its raw size varies with the source and compiler. Keep it under 24 MiB (`packaging/web/package.sh` enforces this; Cloudflare's per-file cap is 25 MiB). Pull-request CI also builds the actual browser app with the same pinned Trunk version as the release job and runs `packaging/web/package.sh`, including the relative-URL and 24 MiB checks. The `web build and wasm size gate` check runs on main and on PRs that change something the web build compiles or packages (`apps/photocraft-web`, `packaging/web`, crate sources and manifests, `Cargo.toml`/`Cargo.lock`, the CI workflow), and reports the resulting wasm size in the Actions job summary. The web build never embeds craft-fonts (see Fonts above). To see where the bytes go, run `twiggy top -n 40` on `target/wasm32-unknown-unknown/wasm-release/photocraft-web.wasm` (before wasm-opt strips the names).URL flags: `?webgl` forces the WebGL2 backend, and `?cpu` forces the CPU canvas path.