Skip to content

Commit 64be11c

Browse files
committed
Correct reflow_rt_wasm README: wgpu does work on wasm
The original copy claimed wgpu native backends block wasm builds. That's wrong — wgpu has a WebGPU backend that compiles to wasm32. The actual blocker for GPU (and fetch, and websocket) actors on wasm is structural: our #[actor(...)] macro bakes a `Send` bound into the future type, and browser-only types are !Send because they hold JS handles (*mut u8) under the hood. Same root cause as the reqwest::AbortGuard issue noted in the previous commit. Spell out the path forward so the constraint is visible.
1 parent 8838f93 commit 64be11c

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

crates/reflow_rt_wasm/README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,25 @@ Currently exposes:
5252
(keyboard, mouse, touch, wheel, resize) into input actors
5353

5454
The bundled component catalog (`reflow_components`) is **not** part
55-
of this crate — its native deps (rquickjs C lib, openh264, wgpu
56-
native backends, …) don't compile to `wasm32-unknown-unknown` without
57-
significant feature-gating. Author actors as JS classes and load
58-
them via `register_actor_js`, or load WASM-compiled actor packs via
59-
the browser pack loader (see [`docs/pack-format.md`](../../docs/pack-format.md)).
55+
of this crate yet. Two unrelated reasons:
56+
57+
1. **`rquickjs` C library** — embedded QuickJS doesn't compile to
58+
`wasm32-unknown-unknown`. Gated to native; the wasm side uses a
59+
`js_sys::Function` shim that calls into the host browser engine
60+
instead.
61+
2. **Actor framework `Send` bounds** — the `#[actor(...)]` macro
62+
wraps each actor's future as `Pin<Box<dyn Future + Send>>`.
63+
Browser-only types are typically `!Send`: `wgpu::WebQueue`,
64+
`reqwest`'s `AbortGuard`, and `web_sys::WebSocket` all hold raw
65+
JS handles (`*mut u8`). On wasm the runtime is single-threaded
66+
and `Send` is moot, but the macro doesn't yet drop the bound on
67+
`target_arch = "wasm32"`. Once that lands, wgpu (which **does**
68+
have a WebGPU backend), browser fetch via reqwest, and
69+
websockets all become available to wasm-side actors.
70+
71+
Author actors as JS classes and load them via `register_actor_js`
72+
in the meantime, or load WASM-compiled actor packs via the browser
73+
pack loader (see [`docs/pack-format.md`](../../docs/pack-format.md)).
6074

6175
## Versioning
6276

0 commit comments

Comments
 (0)