NFSU.cc / Devlog

Hunting a 50-Minute Browser OOM and Shrinking Mobile WASM to 448 MB

Shipping a statically recompiled 2003 PC game to thousands of real browsers surfaces failure modes that desktop tests never hit. Here is what production telemetry caught and how two surgical patches fixed both long-session OOMs and low-RAM phone crashes.

WebAssemblyMemoryWebGPUProduction Telemetry
Commits: 511830f · 921e827 View raw Markdown (.md)

What real browsers broke in production

Once nfsu.cc went live, every unhandled browser crash reported a small JSON payload to our Cloudflare R2 crash bucket (r2:nfsu-crash). Auditing real user sessions revealed two distinct classes of failure:

  1. Memory exhaustion on phones and long desktop sessions: speed_lite.wasm previously requested a 640 MB initial heap, which caused iOS Safari and 4 GB Android devices to fail WebAssembly instantiation (could not allocate memory), while long 50-minute desktop sessions slowly accumulated CPU-side geometry memory.
  2. Browser API edge cases: GPUs without unorm8x4-bgra vertex format support, browsers missing Atomics.waitAsync, tsBuf.unmap() races on timestamp queries, transient network drops during chunk/WASM fetches, and IndexedDB hangs on save boot.

Cutting the 50-minute OOM and dropping speed_lite.wasm to 448 MB (511830f)

Three concrete changes eliminated the memory pressure without touching original 2003 gameplay or audio:

Hardening the WebGPU, audio, and network host (921e827)

Takeaway for browser static recompilation

Emulators usually cap memory tightly up front; static recompilations inherit the original PC executable's allocation assumptions plus a host GPU translation layer. Pairing a lightweight crash beacon with strict CPU-shadow freeing after GPU upload is what makes a 2003 Windows binary survive real mobile browsers.

Files in repo: host/d3d9.c · host/files.c · host/main.c · tools/recomp/build.py · web/gpu.js · web/boot.js · web/audio.js · web/saves.js