Bug Summary
After PR #73 fixed the FFI bridge (bloom_glue.js + build.sh splicing), the game WASM now loads and bootPerryWasm is correctly gated on __bloomReady. The FFI imports (412 bloom_* functions) are registered.
However, the game crashes immediately with WASM Error: unreachable — a WebAssembly trap inside Bloom's WASM functions.
Reproduction
git clone https://github.com/Bloom-Engine/engine.git
cd engine
git submodule update --init --recursive
./native/web/build.sh examples/pong/main.ts
cd dist/web && python3 -m http.server 8080
# Open http://localhost:8080 → "WASM Error: unreachable"
What works
bloom_glue.js loads Bloom WASM, sets __ffiImports (412 functions)
window.__bloomReady Promise resolves
bootPerryWasm is gated correctly (waits for __bloomReady)
- Perry runtime
wrapFfiForI64 wraps FFI namespace with NaN-boxing decode
- Perry WASM instantiates successfully
- Native Linux build works (23.4MB binary, runs with X11 display)
What fails
instance.exports._start() traps with unreachable
- The trap occurs when Perry's game calls Bloom FFI functions (e.g.
bloom_init_window, bloom_set_target_fps, bloom_clear_background)
Environment
Analysis
The unreachable trap suggests Bloom's WASM hits a core::panicked or unreachable!() macro. Likely causes:
- WebGPU/WGPU initialization failure —
bloom_init_window may panic if WebGPU adapter is not available (headless browser / no GPU)
- Canvas not properly attached —
bloom_attach_native may expect a canvas element that isn't ready
- wgpu web backend — the WASM target may need
wgpu web features enabled that aren't compiled in
Expected behavior
The Pong example (or any Bloom game) should render in the browser after build.sh + python3 -m http.server.
Related
Bug Summary
After PR #73 fixed the FFI bridge (
bloom_glue.js+build.shsplicing), the game WASM now loads andbootPerryWasmis correctly gated on__bloomReady. The FFI imports (412bloom_*functions) are registered.However, the game crashes immediately with
WASM Error: unreachable— a WebAssembly trap inside Bloom's WASM functions.Reproduction
What works
bloom_glue.jsloads Bloom WASM, sets__ffiImports(412 functions)window.__bloomReadyPromise resolvesbootPerryWasmis gated correctly (waits for__bloomReady)wrapFfiForI64wraps FFI namespace with NaN-boxing decodeWhat fails
instance.exports._start()traps withunreachablebloom_init_window,bloom_set_target_fps,bloom_clear_background)Environment
Analysis
The
unreachabletrap suggests Bloom's WASM hits acore::panickedorunreachable!()macro. Likely causes:bloom_init_windowmay panic if WebGPU adapter is not available (headless browser / no GPU)bloom_attach_nativemay expect a canvas element that isn't readywgpuweb features enabled that aren't compiled inExpected behavior
The Pong example (or any Bloom game) should render in the browser after
build.sh+python3 -m http.server.Related