1# Fission on the web
2
3Evaluates Fusion `.comp` files with the native `engine` on WebGPU and presents the chosen node to a canvas.
4Standalone crate (`[workspace]` in its own manifest): the native workspace never builds it.
5
6## Build
7
8```sh
9rustup target add wasm32-unknown-unknown
10cargo install wasm-bindgen-cli --version 0.2.128 # must match the `=0.2.128` pin in Cargo.toml
11crates/web/build.sh # -> crates/web/dist/{index.html,pkg/}
12python3 -m http.server -d crates/web/dist 8080 # any static host works
13```
14
15`OUT=/tmp/fission-web-dist PROFILE=release crates/web/build.sh` redirects the output. Needs a browser with WebGPU.
16
17## Use
18
19- **Demo** loads the built-in `demo.comp` (3D simplex `FastNoise`, `Displace`, `TextPlus`, `Merge`, `Glow`, `ColorCorrector`, animated splines and expressions).
20- **Open .comp…**, **Open folder…** or drop a `.comp` / project folder on the page. Images in the folder are registered
21 with `MediaCache::insert_virtual_bytes`; a `Loader` path (even `C:\shots\plate.0001.png`) resolves to the file sharing
22 the longest run of trailing path components. Missing media is listed under the node list.
23- Transport: Play/Pause (Space), scrubber, ←/→ step. The dropdown, the Flow graph and the node list all pick the viewed node.
24
25## Native vs. wasm differences
26
27| Area | wasm32 |
28| --- | --- |
29| Expressions | pure-Rust Lua-subset evaluator (`model::expr`); no statement bodies or method calls |
30| Audio, export, RAM prefetch thread | compiled out |
31| Video loaders | unavailable (no ffmpeg / AVFoundation) |
32| EXR, fonts | not from virtual files / no system fonts (see below) |
33
34## Needs changes outside this crate's claim
35
36The browser cannot render until these land; each is verified by building a patched scratch copy and running it in Chrome (WebGPU, Metal).
37
381. **`std::time::Instant::now()` panics on `wasm32-unknown-unknown`.** `engine/src/eval/mod.rs:11` and `eval/dispatch.rs:4`
39 `use std::time::Instant;` must become `use web_time::Instant;` (`web-time` is already a wasm32 dependency of `engine`;
40 gate it with `cfg(target_arch = "wasm32")` or add it for all targets, where it re-exports `std`).
412. **No fonts**: `text_engine::database()` only loads system fonts, so `TextPlus` renders empty in the browser.
42 It needs a hook to register font bytes (`fontdb::Database::load_font_data`).
433. **EXR from virtual files**: `media/exr.rs::decode_exr_rgba` opens a `File`; it needs a bytes entry point.
444. `eval/io.rs::probe_clip_dims` still reads dimensions from the filesystem for missing media (cosmetic).