Quick answer: Shrink the memory footprint with compressed textures and audio, start with a small heap that grows on demand, and free assets you are done with instead of holding everything in RAM.
Browsers cap how much memory a tab can use, and games hit it easily — particularly on phones. The crash is the browser killing an over-budget tab. Here is how to stay under the limit.
How to fix it
1. Compress and downscale assets
Textures and audio dominate web memory. Use compressed texture formats, cap resolutions, atlas sprites, and stream music instead of decoding it whole into memory.
2. Start small and grow
Configure the engine's heap to start modest and grow as needed rather than reserving a large block up front, which can fail to allocate on low-memory devices before the game even loads.
3. Free what you are done with
Unload assets and dispose of textures, buffers, and audio when leaving a level. A steady memory climb across play is a leak — track down references that keep finished assets alive.
Catching the ones you can't reproduce
The hardest version of this to fix is the one you can't reproduce — it only happens on a player's hardware, OS, driver, or save state, under conditions that simply aren't present on your machine. A report that says “it crashed” or “it froze” gives you nothing to act on, so the bug survives release after release while quietly costing you players.
Automatic error capture closes that gap. Each failure arrives with its full stack trace, the device and OS, the build number, and a breadcrumb trail of what the player did right before it broke, so even a failure you have never seen becomes a specific, reproducible issue. Fold identical failures into one signature ranked by how many players each hits, and your worklist sorts itself worst-first instead of arriving as a stream of vague complaints.
This is where a tool like Bugnet earns its place. Its SDK captures every HTML5 error automatically with the full stack trace plus device, OS, memory, build, and game-state context, folds duplicates into one grouped issue with an occurrence count, and ties each to the build it first appeared on — so you fix the problem that hurts the most players first and confirm it is gone when its signature disappears from the next release.
Ship the fix, watch the signature disappear from the next build. That's how you know it's really gone.