tomassedovic / quicksilver-roguelike

Template for a roguelike in Rust targeting desktop and the web
MIT License
168 stars 10 forks source link

Nothing happens in web mode #6

Open jgarvin opened 4 years ago

jgarvin commented 4 years ago

cloned the repo then did: cargo web start --release --auto-reload

Then it built and said: You can access the web server at http://127.0.0.1:8000

But when I point chrome there I just get an empty white page.

The HTML:

  | <!DOCTYPE html>
-- | --
  | <html>
  | <head><script>
  | window.addEventListener( "load", function() {
  | var current_build_hash = 2901363078;
  | function try_reload() {
  | var req = new XMLHttpRequest();
  | req.addEventListener( "load" , function() {
  | if( req.responseText != current_build_hash ) {
  | window.location.reload( true );
  | }
  | });
  | req.addEventListener( "loadend", function() {
  | setTimeout( try_reload, 500 );
  | });
  | req.open( "GET", "/__cargo-web__/build_hash" );
  | req.send();
  | }
  | try_reload();
  | });
  | </script>
  | <meta charset="utf-8" />
  | <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  | <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" name="viewport" />
  | <script>
  | var Module = {};
  | var __cargo_web = {};
  | Object.defineProperty( Module, 'canvas', {
  | get: function() {
  | if( __cargo_web.canvas ) {
  | return __cargo_web.canvas;
  | }
  |  
  | var canvas = document.createElement( 'canvas' );
  | document.querySelector( 'body' ).appendChild( canvas );
  | __cargo_web.canvas = canvas;
  |  
  | return canvas;
  | }
  | });
  | </script>
  | </head>
  | <body>
  | <script src="quicksilver-roguelike.js"></script>
  | </body>
  | </html>

When I click quicksilver-roguelike.js in the view source display it loads the source so it seems like it find the code.

jaxs-ribs commented 4 years ago

I seem to get the same error. Any suggestions?

tomassedovic commented 4 years ago

I've managed to reproduce this locally and the browser console had this error:

Uncaught (in promise) RuntimeError: unreachable
    at __rust_start_panic (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3915]:0xa5efc)
    at rust_panic (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3909]:0xa5bf7)
    at _ZN3std9panicking20rust_panic_with_hook17h5395f3796c27894aE (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3904]:0xa591b)
    at rust_begin_unwind (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3903]:0xa5823)
    at _ZN3std9panicking15begin_panic_fmt17hb93f5888ffb2388eE (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3874]:0xa4747)
    at _ZN3std3env8_set_var28_$u7b$$u7b$closure$u7d$$u7d$17h4b1a4c57d7067e86E (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3878]:0xa4c9b)
    at _ZN3std3env8_set_var17h569573896d882f42E (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[3877]:0xa4c07)
    at _ZN3std3env7set_var17h312ea2193e8595ecE (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[640]:0x1df48)
    at _ZN21quicksilver_roguelike4main17hc8845eafda5ae7c5E (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[1083]:0x32f4c)
    at _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17h8661623101b55bf5E (http://localhost:8000/quicksilver-roguelike.wasm:wasm-function[236]:0x88b8)

Seems like something is panicking in the compiled wasm module. Unfortunately, I'm not sure what or how to fix it :-(.

I've tried to comment out all of the implementation details in the tutorial and the error still persists so this is probably something in Quicksilver or some of its dependencies.

Honestly, I think at this point it's probably better to wait for the version 0.4 of quicksilver. But that version is still not completely done and the docs are not fully updated, so I'm kind of waiting for that.

If you want to dig into debugging this issue or updating the tutorial to work with 0.4-alpha, I'll be happy to give it a look! But I don't have any good suggestions and I won't be able to do it myself any time soon.