Skip to content

emscripten support is broken (since wasm-bindgen does not work there?) #810

Description

@benjamin-sieffert

When I try to use cpal (via rodio) in an emscripten build, I first need to apply this patch:

--- a/src/lib.rs
+++ b/src/lib.rs
@@ -243,7 +243,7 @@ impl wasm_bindgen::describe::WasmDescribe for BufferSize {
 
 #[cfg(target_os = "emscripten")]
 impl wasm_bindgen::convert::IntoWasmAbi for BufferSize {
-    type Abi = wasm_bindgen::convert::WasmOption<u32>;
+    type Abi = Option<u32>;
     fn into_abi(self) -> Self::Abi {
         match self {
             Self::Default => None,

Then I can compile and run into the following error:
"cannot call wasm-bindgen imported functions on non-wasm targets" @ /home/ax/.cargo/registry/src/index.crates.io-6f17d22bba15001f/web-sys-0.3.64/src/features/gen_AudioContext.rs:5
Afaik, wasm-bindgen fundamentally does not work on emscripten, at least not without jumping through a lot of hoops.

Before #713 , "stdweb" was used, which advertises direct emscripten support; so it probably (somewhat) worked at some point.
Unfortunately the old version(s) can no longer be compiled, due to various other changes in rustc/libc/emscripten.

According to the emscripten docs, "OpenAL" should be the best way to get audio in that environment: https://emscripten.org/docs/porting/Audio.html

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions