ungverd / monkey_game

SDL WASM game
1 stars 0 forks source link

Browser just shows a blank page #1

Open inhahe opened 3 hours ago

inhahe commented 3 hours ago

So I did

source ./emsdk/emsdk_env.sh 
git clone https://github.com/ungverd/monkey_game.git
cd monkey_game/ 
emcc mygame.c -s WASM=1 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s SDL2_IMAGE_FORMATS='["png"]' --preload-file assets -o index.js
google-chrome index.html 

And there were no errors up to that point, but it just doesn't run. All I get is a blank page. I waited for a while. Here's Chrome's terminal output:

libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[4769:4769:1104/230612.324374:ERROR:object_proxy.cc(576)] Failed to call method: org.freedesktop.ScreenSaver.GetActive: object_path= /org/freedesktop/ScreenSaver: org.freedesktop.DBus.Error.NotSupported: This method is not implemented
[4857:8:1104/230612.741194:ERROR:command_buffer_proxy_impl.cc(131)] ContextResult::kTransientFailure: Failed to send GpuControl.CreateCommandBuffer.
Created TensorFlow Lite XNNPACK delegate for CPU.
[4769:4796:1104/230618.739311:ERROR:registration_request.cc(291)] Registration response error message: DEPRECATED_ENDPOINT
[4813:4813:1104/230619.525604:ERROR:gles2_cmd_decoder_passthrough.cc(1053)] [GroupMarkerNotSet(crbug.com/242999)!:A0A020004C190000]Automatic fallback to software WebGL has been deprecated. Please use the --enable-unsafe-swiftshader flag to opt in to lower security guarantees for trusted content.

And here's the console output in developer mode:

Access to fetch at 'file:///home/inhahe/monkey_game/index.data' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.Understand this errorAI
index.data:1 

       Failed to load resource: net::ERR_FAILEDUnderstand this errorAI
index.js:81 Uncaught (in promise) Error: Network Error: index.data
    at index.js:81:44Caused by: TypeError: Failed to fetch
    at fetchRemotePackage (index.js:80:9)
    at loadPackage (index.js:140:21)
    at index.js:222:5
    at index.js:224:5Understand this errorAI
index.html:1 Access to XMLHttpRequest at 'file:///home/inhahe/monkey_game/index.wasm' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: chrome, chrome-extension, chrome-untrusted, data, http, https, isolated-app.Understand this errorAI
index.js:872 failed to asynchronously prepare wasm: both async and sync fetching of the wasm failed
(anonymous) @ index.js:872Understand this errorAI
index.js:876 warning: Loading from a file URI (file:///home/inhahe/monkey_game/index.wasm) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing
(anonymous) @ index.js:876Understand this errorAI
index.js:775 Aborted(both async and sync fetching of the wasm failed)
abort @ index.js:775Understand this errorAI
index.wasm:1 

       Failed to load resource: net::ERR_FAILEDUnderstand this errorAI
index.js:793 Uncaught (in promise) RuntimeError: Aborted(both async and sync fetching of the wasm failed)
    at abort (index.js:793:11)

So I'm looking for some help to get any C or C++ wasm program that uses SDL2 working so that I can use it as a basis on which to make my own program...I've tried a few github programs, tutorial examples, etc., and I can't get anything working, that's why I'm looking for help here. Thanks.

inhahe commented 3 hours ago

Nevermind, I figured out I had to load it from the web instead of from file, so I uploaded it to my webserver, and it worked. Thanks.