lord / wargo

Easy Rust to WebAssembly
MIT License
261 stars 9 forks source link

Error executing the example in the browser #17

Open nuxlli opened 7 years ago

nuxlli commented 7 years ago

I followed all the steps of the article https://lord.io/blog/2017/wargo/ However I'm getting the following errors when I try to access the http://127.0.0.1:8080:

screen shot 2017-10-27 at 14 25 55

lord commented 7 years ago

Are you doing the wargo-loader example with Webpack? Do you think you could post the output of running wargo test in your project?

nuxlli commented 7 years ago

Yes, I was testing the wargo-loader.

Shows the results for the wargo test:

▶ wargo test
  Setup wasm checking dependencies...
  Setup wasm found emsdk installation in ~/.emsdk
  Setup wasm setting environment...
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 1.37.22
clang version 4.0.0  (emscripten 1.37.22 : 1.37.22)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Users/nuxlli/.emsdk/clang/e1.37.22_64bit
INFO:root:(Emscripten: Running sanity checks)
  Setup wasm running 'cargo test --target=wasm32-unknown-emscripten --no-run'
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
  Setup wasm running 'cargo test --target=wasm32-unknown-emscripten --no-run --message-format=json'
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
  Setup wasm running tests...
wasm streaming compile failed: TypeError: Incorrect response MIME type. Expected 'application/wasm'.
falling back to ArrayBuffer instantiation
pre-main prep time: 895 ms

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

screen shot 2017-10-27 at 16 49 51

yuxineverforever commented 6 years ago

Have you found any solution yet? The same problem happened in my browser.

jamestaylr commented 6 years ago

I could also reproduce this issue on macOS 10.13. It appears to be darwin specific, as I could get it running if I compiled on Linux. I'm not sure if this is an issue specific to wargo or the Rust compiler itself.

togakangaroo commented 6 years ago

It is happening for me on the mac as well

The error seems to be the wasm instantiation failing

    function instantiateArrayBuffer(receiver) {
      getBinaryPromise().then(function(binary) {
        return WebAssembly.instantiate(binary, info);
      }).then(receiver).catch(function(reason) {
        Module['printErr']('failed to asynchronously prepare wasm: ' + reason);
        abort(reason);
      });
    }

If anyone wants to jump on a call and troubleshoot I can demo the issue (I personally don't really know rust or webpack)