Missing canvas + links
AntonOellerer opened this issue · 13 comments
When I try to run the example projects, the console tells me it can't find the canvas, the js code and the wasm file, I needed to add the following lines:
<canvas id="canvas" width="640" height="480"></canvas>
<script type="text/javascript">
var Module = {
"canvas": document.getElementById('canvas'),
"wasmBinaryFile": "./target/wasm32-unknown-emscripten/release/deps/rust_webassembly_array-f3ee49d945ae98 22.wasm"
};
</script>
furthermore I had to change the script source to "./target/wasm32-unknown-emscripten/release/rust-webassembly-array.js"
It seems like the binary file name gets generated, I don't really know how to fix that
@Acru2015 I don't think that any of my examples use the Canvas element, so I'm not really sure where that requirement is coming from.
The binary file name is definitely generated, or at least includes a hash. You should be able to work around this using a symlink like; ln -s ./path/to/binary/*.wasm ./other/path/app.wasm
I updated the index.html here:
If you are interested I can try the ln
fix aswell
@Acru2015 I'd love to understand where the 'canvas is missing' error is coming from. Do you happen to know if this is a new requirement from emscripten?
I think so, but I don't know since when/why
Did you try to reproduce it on you machine?
Yeah, I just pulled down the project, and was able to build and run the string example without issue. Can you tell me what version of emsdk you are running ?
emcc --version
emcc (Emscripten gcc/clang-like replacement) 1.37.12 ()
Funny
emcc (Emscripten gcc/clang-like replacement) 1.37.21
Yeah very strange. I'll try to take some time in the next couple of days to upgrade to the latest of emcc and see if I can reproduce the issue.
I am using Firefox 56.0 btw
At the struct example I am getting the warning
failed to asynchronously prepare wasm: ReferenceError: str is not defined
shell_printErr @ hello-cargo.js:formatted:159
(anonymous) @ hello-cargo.js:formatted:1379
Promise rejected (async)
doNativeWasm @ hello-cargo.js:formatted:1378
Module.asm @ hello-cargo.js:formatted:1451
(anonymous) @ hello-cargo.js:formatted:6045
if you encounter the same error after upgrading, I fixed it here
Removed the struct example, as it wasn't really a struct example. I couldn't replicate the issue you reported on the latest version of emsdk using Chrome or FF
Closing as unable to reproduce. All examples tested using latest emsdk and the Makefile tasks work as expected