You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drop Send/Sync from Actor + ActorBehavior + ActorState on wasm32
The actor framework required `Send + Sync` everywhere because the
native runtime drives actors on tokio's multi-threaded executor.
On `wasm32-unknown-unknown` the runtime is single-threaded
(`spawn_local`) and the bound is gratuitous — but it was rejecting
every browser-only type that holds raw JS handles (`*mut u8`):
- `wgpu::backend::webgpu::WebQueue/WebTexture/WebBuffer`
- `reqwest::wasm::AbortGuard`
- `web_sys::WebSocket`, `web_sys::GpuDevice`, …
Fixes:
- Introduce `MaybeSend` / `MaybeSync` marker traits. Both collapse
to `Send` / `Sync` on native and to nothing on wasm32. Use these
for trait supertraits (`Actor`, `ActorState`).
- For `dyn Future + Send` trait objects, marker traits don't help
(Rust forbids combining a custom trait with a non-auto trait in
a dyn). Cfg-split `ActorBehavior`, `Actor::create_process`,
`ActorProcess::into_future`, and `Network::init_process` to drop
`+ Send` on wasm.
- Tidy reflow_components: gate `crate::io::FileLoadActor/FileSaveActor`
imports + registry entries to native (already done at the module
level, but the registry imports were unconditional). Document gpu
module as "feature-gated wgpu pieces are native-only — sdf path
utilities and font atlas math stay available to wasm consumers".
Result: `cargo check --target wasm32-unknown-unknown -p reflow_components`
is clean. The wgpu/openh264/chromiumoxide-feature actors remain
native-only — those need separate work for the wgpu+wasm async init
story (no `pollster::block_on` in browser).
0 commit comments