stanoddly / DotnetRaylibWasm

Prototype for .NET 7 with Raylib compiled into WebAssembly (wasm)
MIT License
61 stars 8 forks source link

The page occasionally dies with STATUS_BREAKPOINT / Out of memory #1

Closed stanoddly closed 1 year ago

stanoddly commented 1 year ago

The page occasionally dies with STATUS_BREAKPOINT, no repro steps yet.

image

stanoddly commented 1 year ago

Happened again, I just opened the page, left it in background (still visible) while writing this bug report and it happened on its own in the background.

stanoddly commented 1 year ago

Well, Chrome was more explicit about the failure. image

stanoddly commented 1 year ago

I read more about the flags and I found that asyncify has a performance impact according to the documentation.

As mentioned earlier, unoptimized builds with Asyncify can be large and slow. Build with optimizations (say, -O3) to get good results.

Asyncify adds overhead, both code size and slowness, because it instruments code to allow unwinding and rewinding. That overhead is usually not extreme, something like 50% or so. Asyncify achieves that by doing a whole-program analysis to find functions need to be instrumented and which do not - basically, which can call something that reaches one of ASYNCIFY_IMPORTS. That analysis avoids a lot of unnecessary overhead, however, it is limited by indirect calls, since it can’t tell where they go - it could be anything in the function table (with the same type).

After removal of -sASYNCIFY the page has been running for like 10 (?) minutes already without any issue. 🎉

While it removes the native loop, this is not such a big deal because a relatively simple change in the code can "unloop" the loop and move the loop to Javascript.

stanoddly commented 1 year ago

a relatively simple change in the code can "unloop" the loop and move the loop to Javascript.

Actually this is achievable from C# as well using await Task.Delay(millis).

stanoddly commented 1 year ago

Closing since it was caused by ASYNCIFY which isn't necessary after all.