floooh/sokol-zig

Shapes example won't work in Firefox

Closed this issue · 2 comments

Error when running:
zig build run-shapes -Dtarget=wasm32-emscripten

Error details:

Uncaught RuntimeError: unreachable executed tick http://localhost:6931/shapes.js:1725
In the function 'if' statement:

var _emscripten_request_animation_frame_loop = (cb, userData) => {
  function tick(timeStamp) {
    if (getWasmTableEntry(cb)(timeStamp, userData)) {
      requestAnimationFrame(tick);
    }
  }
  return requestAnimationFrame(tick);
};
  • "clear" example did work.
  • c version did work from site.
  • Tested with Firefox.

The problem is in these lines:

var vertices: [6 * 1024]sshape.Vertex = undefined;
var indices: [16 * 1024]u16 = undefined;

Those arrays are too large, that causes segmentation fault, consider using heap allocations.

Ah, the Emscripten stack size reduction strikes again :/ (a little while ago, Emscripten reduced the default stack size to 64 KBytes).

I fixed the problem like this instead:

c5bdb50

PS: thanks for taking the time to write the ticket, much appreciated :)