Running on the Web
Pebble builds for wasm32-unknown-unknown — WindowPlugin’s runner and the whole rendering pipeline are written to work unmodified on both native and web. A few things differ:
- The canvas is inserted automatically.
winitdoesn’t do this on its own;WindowPluginasks it to (with_append(true)) so a window actually shows up in the page without hand-rolled DOM code. - The event loop is non-blocking. Natively,
winit’srunblocks forever; on wasm it usesEventLoopExtWebSys::spawn, which registers the loop with the browser and returns immediately. This is handled insideWindowPlugin— you don’t need to branch on it yourself. - The default headless loop busy-polls instead of sleeping. There’s no real OS thread to sleep on wasm, so if you never register a windowing plugin (uncommon), the fallback loop just spins. In practice this path is only reached before a windowing plugin’s runner takes over.
- No
ADDRESS_MODE_CLAMP_TO_BORDER. The GPU backend requests this feature only on native;SamplerKind::NearestClampBorderfalls back to clamp-to-edge on wasm accordingly.
Building:
cargo build --target wasm32-unknown-unknown
You’ll still need your own bundling/serving setup (wasm-bindgen, trunk, or similar) — pebble doesn’t ship one.