Repository navigation
Open
Description
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.jsloads Bloom WASM, sets__ffiImports(412 functions)window.__bloomReadyPromise resolvesbootPerryWasmis gated correctly (waits for__bloomReady)- Perry runtime
wrapFfiForI64wraps 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 withunreachable- The trap occurs when Perry's game calls Bloom FFI functions (e.g.
bloom_init_window,bloom_set_target_fps,bloom_clear_background)
Environment
- Bloom Engine: commit 71fedc9 (PR fix(web): integrate compiled game WASM into the web build (#72) #73 merged)
- Perry: v0.5.1182 (latest from npm)
- Rust 1.96.0, wasm-pack 0.15.0
- Browser: Chromium (headless)
- OS: Debian 13 (Linux x86_64)
Analysis
The unreachable trap suggests Bloom's WASM hits a core::panicked or unreachable!() macro. Likely causes:
- WebGPU/WGPU initialization failure —
bloom_init_windowmay panic if WebGPU adapter is not available (headless browser / no GPU) - Canvas not properly attached —
bloom_attach_nativemay expect a canvas element that isn't ready - wgpu web backend — the WASM target may need
wgpuweb 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
- Web build: bloom_glue.js bootBloomGame() doesn't load game.wasm — FFI bridge incomplete #72 — original FFI bridge bug (fixed by fix(web): integrate compiled game WASM into the web build (#72) #73)
- fix(web): integrate compiled game WASM into the web build (#72) #73 — FFI bridge fix (this bug persists after that fix)
Metadata
Metadata
Assignees
Labels
No labels
Activity