ftsf / nico

a Game Framework in Nim inspired by Pico-8.
MIT License
624 stars 35 forks source link

How to run compiled WASM example? #106

Closed matkuki closed 1 year ago

matkuki commented 1 year ago

Hi, great library by the way!

I have compiled the example project created with nicoboot to WASM with nimble webd then using python to serve the directory, but opening the http://localhost:8000/ shows a dark window and this in the console:

This page is in Quirks Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”. localhost:8000
The script from “http://localhost:8000/wasm_test.js” was loaded even though its MIME type (“text/plain”) is not a valid JavaScript MIME type. localhost:8000
Use of drawWindow method from CanvasRenderingContext2D is deprecated. Use tabs.captureTab extensions API instead https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/tabs/captureTab pagedata-script.js:1:12439
added game controller: -1: Keyboard: KEYBOARD wasm_test.js:1765:16
basePath: , / wasm_test.js:1765:16
assetPath: , /assets wasm_test.js:1765:16
writePath: , /IDBFS wasm_test.js:1765:16
initConfig wasm_test.js:1765:16
start file sync.. wasm_test.js:1194:75
initMixer wasm_test.js:1765:16
An AudioContext was prevented from starting automatically. It must be created or resumed after a user gesture on the page. wasm_test.js:1197:262
opened audio output , 44100,  channels: , 2,  format: , 8120 wasm_test.js:1765:16
audio initialised using main thread wasm_test.js:1765:16
loadConfig wasm_test.js:1765:16
no config file loaded wasm_test.js:1765:16
loading font from indexed, wasm_test.js:1765:16
loading font  with 94 chars, width: 381 wasm_test.js:1765:16
loaded font with 94/94 chars wasm_test.js:1765:16
updating current font , 0 wasm_test.js:1765:16
Uncaught (in promise) TypeError: eventHandler.target is null
    registerOrRemoveHandler http://localhost:8000/wasm_test.js:6165
    registerMouseEventCallback http://localhost:8000/wasm_test.js:8831
    _emscripten_set_mousemove_callback_on_thread http://localhost:8000/wasm_test.js:8849
    createExportWrapper http://localhost:8000/wasm_test.js:905
    callMain http://localhost:8000/wasm_test.js:10313
    doRun http://localhost:8000/wasm_test.js:10363
    run http://localhost:8000/wasm_test.js:10378
    runCaller http://localhost:8000/wasm_test.js:10291
    removeRunDependency http://localhost:8000/wasm_test.js:834
    receiveInstance http://localhost:8000/wasm_test.js:1048
    receiveInstantiationResult http://localhost:8000/wasm_test.js:1067
    promise callback*instantiateAsync/< http://localhost:8000/wasm_test.js:1003
    promise callback*instantiateAsync http://localhost:8000/wasm_test.js:995
    createWasm http://localhost:8000/wasm_test.js:1086
    <anonymous> http://localhost:8000/wasm_test.js:9948
wasm_test.js:6165:11
syncfs done wasm_test.js:1194:163
null wasm_test.js:1194:192
initConfigDone wasm_test.js:1765:16
end file sync.. wasm_test.js:1194:255

Here is the browser screenshot of the error: image

Any ideas of what I did wrong? Thanks

matkuki commented 1 year ago

I also tried on Linux (Ubuntu), same error is thrown.

matkuki commented 1 year ago

To successfully compile and run for eanyone else reading this its:

$ nimble webd
$ emcc projectname.html

as discussed in: #104