browser-wasm hell

i'm trying to use raylib with browser-wasm and i get error whenever i try to call something from raylib:
MONO_WASM: at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object , Span`1 , BindingFlags )
ManagedError@http://localhost:52900/_framework/dotnet.runtime.js:3:26843
Jn@http://localhost:52900/_framework/dotnet.runtime.js:3:31615
kr@http://localhost:52900/_framework/dotnet.runtime.js:3:35530
Ml/e.onRuntimeInitialized/l.javaScriptExports.call_entry_point@http://localhost:52900/_framework/dotnet.runtime.js:3:209315
Fc@http://localhost:52900/_framework/dotnet.runtime.js:3:136994
Mc@http://localhost:52900/_framework/dotnet.runtime.js:3:136420
run@http://localhost:52900/_framework/dotnet.js:3:35124
@http://localhost:52900/main.js:17:14
logging.ts:32:12
d logging.ts:32
Me exit.ts:161
Me exit.ts:52
Mc run.ts:22
MONO_WASM: at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object , Span`1 , BindingFlags )
ManagedError@http://localhost:52900/_framework/dotnet.runtime.js:3:26843
Jn@http://localhost:52900/_framework/dotnet.runtime.js:3:31615
kr@http://localhost:52900/_framework/dotnet.runtime.js:3:35530
Ml/e.onRuntimeInitialized/l.javaScriptExports.call_entry_point@http://localhost:52900/_framework/dotnet.runtime.js:3:209315
Fc@http://localhost:52900/_framework/dotnet.runtime.js:3:136994
Mc@http://localhost:52900/_framework/dotnet.runtime.js:3:136420
run@http://localhost:52900/_framework/dotnet.js:3:35124
@http://localhost:52900/main.js:17:14
logging.ts:32:12
d logging.ts:32
Me exit.ts:161
Me exit.ts:52
Mc run.ts:22
here's my Program.cs: https://hastebin.skyra.pw/ewuqobipew.csharp and .csproj: https://hastebin.skyra.pw/hokisihaje.htm
10 Replies
canton7
canton77d ago
Maybe I'm missing something but.... Isn't the entire point of the browser sandbox, and use of WASM, to prevent people from running arbitrary native code?
danilwaffle
danilwaffle7d ago
this should be possible i referenced DotnetRaylibWasm but it crashes when you try to enter loop now it doesn't even begin maybe i need directpinvoke? or is it thing for static library oh it didn't copy it to the folder
canton7
canton77d ago
As in, https://github.com/stanoddly/DotnetRaylibWasm? I don't see any static libraries in their csproj? But maybe I'm missing a bit of how this all works
GitHub
GitHub - stanoddly/DotnetRaylibWasm: Prototype for .NET 7 with Rayl...
Prototype for .NET 7 with Raylib compiled into WebAssembly (wasm) - stanoddly/DotnetRaylibWasm
danilwaffle
danilwaffle7d ago
weird
canton7
canton77d ago
Ah, I see you've copied their csproj (I was looking at the Examples csproj, which is normally a good place to start)
danilwaffle
danilwaffle7d ago
examples are just normal raylib-cs' examples waow, i renamed libraylib.a to raylib.a and it booted
danilwaffle
danilwaffle7d ago
now it's same issue as in dotnetraylibwasm
No description
danilwaffle
danilwaffle7d ago
oh chrome gives more details seems like it's aot issue it doesn't seem i can export emscripten functions 0>EXEC: Warning : invalid item in EXPORTED_RUNTIME_METHODS: emscripten_set_main_loop
danilwaffle
danilwaffle7d ago
i guess no asyncify for me
No description
danilwaffle
danilwaffle6d ago
here we go again, back to wasm hell now i have this code:
internal unsafe partial class Program
{
private delegate void em_callback_func();

[LibraryImport("__Internal_emscripten")]
private static partial void emscripten_set_main_loop(
em_callback_func callback,
int fps,
byte simulate_infinite_loop
);

public static void Main(string[] args)
{
const int screenWidth = 800;
const int screenHeight = 450;

InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
emscripten_set_main_loop(Update, 0, 1);
CloseWindow();
}

private static void Update()
{
BeginDrawing();
ClearBackground(new Color(245, 245, 245, 255));

DrawText("Congrats! You created your first window!", 190, 200, 20, new Color(100, 100, 100, 255));

EndDrawing();
}
}
internal unsafe partial class Program
{
private delegate void em_callback_func();

[LibraryImport("__Internal_emscripten")]
private static partial void emscripten_set_main_loop(
em_callback_func callback,
int fps,
byte simulate_infinite_loop
);

public static void Main(string[] args)
{
const int screenWidth = 800;
const int screenHeight = 450;

InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
emscripten_set_main_loop(Update, 0, 1);
CloseWindow();
}

private static void Update()
{
BeginDrawing();
ClearBackground(new Color(245, 245, 245, 255));

DrawText("Congrats! You created your first window!", 190, 200, 20, new Color(100, 100, 100, 255));

EndDrawing();
}
}
No description
Want results from more Discord servers?
Add your server