planetis-m / naylib

Yet another raylib Nim wrapper
MIT License
209 stars 11 forks source link

Audio not working in web version #68

Closed waozixyz closed 1 year ago

waozixyz commented 1 year ago

When trying to use the raylib audio functions i get the following error

index.js:1385 Uncaught TypeError: Module._malloc is not a function
    at 125255 (index.js:1385:458)
    at runEmAsmFunction (index.js:4019:31)
    at _emscripten_asm_const_int (index.js:4022:14)
    at imports.<computed> (index.js:8605:35)
    at index.wasm:0x115034
    at index.wasm:0x6277e
    at index.wasm:0x66d59
    at index.wasm:0x10bac3
    at index.wasm:0x24b8ec
    at index.wasm:0x2508e1
125255 @ index.js:1385
runEmAsmFunction @ index.js:4019
_emscripten_asm_const_int @ index.js:4022
imports.<computed> @ index.js:8605
$func877 @ index.wasm:0x115034
$func490 @ index.wasm:0x6277e
$func499 @ index.wasm:0x66d59
$func853 @ index.wasm:0x10bac3
$func1598 @ index.wasm:0x24b8ec
$func1626 @ index.wasm:0x2508e1
$func1625 @ index.wasm:0x2506a4
$func1627 @ index.wasm:0x250b2f
$main @ index.wasm:0x250ccc
ret.<computed> @ index.js:8639
(anonymous) @ index.js:1093
callMain @ index.js:9791
doRun @ index.js:9841
(anonymous) @ index.js:9852
setTimeout (async)
run @ index.js:9848
runCaller @ index.js:9769
removeRunDependency @ index.js:1018
receiveInstance @ index.js:1238
receiveInstantiationResult @ index.js:1257
Promise.then (async)
(anonymous) @ index.js:1191
Promise.then (async)
instantiateAsync @ index.js:1183
createWasm @ index.js:1273
(anonymous) @ index.js:9372

if i remove any audio functions such as initAudoDevices everything else works and i get no errors

planetis-m commented 1 year ago

I cannot reproduce, I compiled with nim c --mm:orc --panics:on -d:release -d:emscripten raylib_game.nim and run with emrun raylib_game.html Sound works. What's your build command?

waozixyz commented 1 year ago

for testing purposes im trying to use the basic_window_web.nim file in the raylib-examples/core folder

i also tried to run the arguments you suggested but once i add the line

  initAudioDevice()    

into proc main i get the same exception thrown :/

i have not done any additional changes to that repo

planetis-m commented 1 year ago

I have done what you said, still nothing. Do you get the same error when using the C library? https://github.com/raysan5/raylib/wiki/Working-for-Web-(HTML5) εικόνα

planetis-m commented 1 year ago

I will review the official Makefile and see what configuration you're missing. Have you installed emscripten with a package manager?

waozixyz commented 1 year ago

okay i have tried running the c version now and building the example and i am getting the same issue, sorry this isn't a naylib issue. i must be doing something wrong.

i have the latest emsdk following the raylib instructions.. :/