HTML5 build: Black screen and errors in console

I am trying to make an HTML5 build of a game mechanic prototype and I’m running into some issues. The game just sticks on a black screen. The errors I get in Chrome seem related to the heap size (“memory access out of bounds”), though the errors in Firefox are slightly different and don’t show up in my forum searches (“index out of bounds”).

Console errors in Firefox
This page uses the non standard property “zoom”. Consider using calc() in the relevant property values, or using “transform” along with “transform-origin: 0 0”. space-combat-v1
Loading failed for the <script> with source “https://www.google-analytics.com/analytics.js”. space-combat-v1:1:1
Feature Policy: Skipping unsupported feature name “autoplay”. lib.js:3:3975
Feature Policy: Skipping unsupported feature name “midi”. lib.js:3:3975
Feature Policy: Skipping unsupported feature name “autoplay”. lib.js:3:3975
Feature Policy: Skipping unsupported feature name “midi”. lib.js:3:3975
Feature Policy: Skipping unsupported feature name “autoplay”. lib.js:3:15816
Feature Policy: Skipping unsupported feature name “midi”. lib.js:3:15816
Running... dmloader.js:349:41
<empty string> dmloader.js:349:41
WebGL warning: getParameter: pname: Invalid enum value MAX_ELEMENTS_VERTICES space_combat_wasm.js:1:191067
WebGL warning: getParameter: pname: Invalid enum value MAX_ELEMENTS_INDICES space_combat_wasm.js:1:191067
exception thrown: RuntimeError: index out of bounds,@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[5082]:0x1e36e3
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[5088]:0x1e55b4
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[5089]:0x1e5749
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[3629]:0x15fe0b
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[756]:0x28d43
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[755]:0x28b6f
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1287]:0x60211
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[839]:0x2f5ac
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1292]:0x603e3
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1295]:0x609dd
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[839]:0x2f630
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1247]:0x5dd82
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1249]:0x5df0a
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[839]:0x2f630
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1218]:0x5bd0a
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[1221]:0x5c3c4
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[839]:0x2f630
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[712]:0x232e6
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[711]:0x230e0
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[839]:0x2f630
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[704]:0x22541
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[703]:0x22358
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[839]:0x2f630
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[453]:0x9ded
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[461]:0xb51c
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[448]:0x7f5a
@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat.wasm:wasm-function[447]:0x7efb
Module._main@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat_wasm.js:1:345175
callMain@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/space_combat_wasm.js:1:356049
_preloadAndCallMain@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/dmloader.js:666:24
onArchiveLoaded@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/dmloader.js:554:20
onPieceLoaded@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/dmloader.js:222:47
requestPiece/xhr.onload@https://v6p9d9t4.ssl.hwcdn.net/html/2205083/dmloader.js:163:21
dmloader.js:347:40
RuntimeError: index out of bounds space_combat.wasm:1980131:1
INFO:CRASH: Successfully wrote Crashdump to file: /data/.Defold/_crash dmloader.js:346:37
Exception thrown, see JavaScript console dmloader.js:349:41
Console errors in Chrome

dmloader.js:347 exception thrown: RuntimeError: memory access out of bounds,RuntimeError: memory access out of bounds at wasm-function[5082]:0x1e36e3 at wasm-function[5088]:0x1e55b4 at wasm-function[5089]:0x1e5749 at wasm-function[3629]:0x15fe0b at wasm-function[756]:0x28d43 at wasm-function[755]:0x28b6f at wasm-function[1287]:0x60211 at wasm-function[839]:0x2f5ac at wasm-function[1292]:0x603e3 at wasm-function[1295]:0x609dd

printErr @ dmloader.js:347
callMain @ space_combat_wasm.js:1
_preloadAndCallMain @ dmloader.js:666
onArchiveLoaded @ dmloader.js:554
onPieceLoaded @ dmloader.js:222
xhr.onload @ dmloader.js:163
load (async)
requestPiece @ dmloader.js:157
requestContent @ dmloader.js:122
onPieceLoaded @ dmloader.js:218
xhr.onload @ dmloader.js:163
load (async)
requestPiece @ dmloader.js:157
requestContent @ dmloader.js:122
onPieceLoaded @ dmloader.js:218
xhr.onload @ dmloader.js:163

My settings:
image
I’ve tried it with and without the engine arguments, and have tried the heap size at 256, 512, and 1024.

Any ideas?

How many atlases you have and what size of atlases?

Ah, didn’t think that could be a problem! I have 11 atlases, some quite large with the biggest one being 8192x4096. Like I mentioned it’s a prototype so I didn’t bother with optimisation at all. What’s the limit, if there is one?

Pushed the biggest atlas down to 4096x4096 and still getting the same error, so I’m assuming it’s lower than that.

I saw a similar problem many times. In most of cases, it is a problem with a big amount of huge atlases.

That’s going to be a lot of memory! Assuming every texture is 2048x2048: 2048x2048x4x11 = 184MB x 1.33 (for mipmaps) = 245MB

I’m guessing some are larger and some are smaller, but still, it’s a lot of memory. A single 4096x4096 texture is 90MB incl. mipmaps.

Some notes on optimising graphics: https://defold.com/manuals/optimization/#optimize-graphics

I would start by creating a texture profile and setting max texture size to for instance 1024x1024. You can also disable mipmaps. More info: https://defold.com/manuals/texture-profiles/#profiles