Skip to content

Web: Bloom WASM functions trap with 'unreachable' after FFI bridge fix (#73) #74

Description

@babang1da

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:

  1. WebGPU/WGPU initialization failurebloom_init_window may panic if WebGPU adapter is not available (headless browser / no GPU)
  2. Canvas not properly attachedbloom_attach_native may expect a canvas element that isn't ready
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions