I exported a game to HTML5 with emscripten via this tutorial on a Windows 11 machine, then uploaded the resulting files to a Linux webserver. The files are all appropriately named index.html, js, etc. Upon visiting the site, the game immediately stops with __emscripten_stack_alloc is not a function.
I looked through index.js, and __emscripten_stack_alloc occurs twice:
var __emscripten_stack_alloc = wasmExports["Gk"];
and
var stackAlloc = sz => __emscripten_stack_alloc(sz);
I’m not sure what’s happening here. Does emscripten need to be installed on the host server as well? It’s just a compiler that translates code into webassembly, so I’d be very surprised, but nothing’s off the table at this point.
That is a good idea. I just tried it, but I get the same exact error on localhost as on itch.io and the linux webserver. Looks like it’s platform-agnostic and something’s wrong with the code itself.
After getting help from others in the official Godot discord, I solved this problem by recompiling the web assembly templates in an earlier version of emscripten. I used 3.1.48 after reading this reddit post and it resulted in a different error about dynamic linking not enabled. Not the best, but still progress!
According to the help received from the discord, when compiling from source, it’s apparently a good idea to use the exact version of Emscripten that was used for the official build. The exact version, noted in the 3.5.3 documentation, is 1.39+. I’m going to experiment further with which specific version works, but that solved my initial problem. The very latest versions of Emscripten may easily break things in Godot.