HTML export crashes when new generation in evolution based algorithm is starting

Godot Version

v4.4.1.stable.flathub [49a5bc7b6]

Question

The most reset (testing) version of my game AntiBillard is crashing if and only if I export it as HTML. (My last HTML export is on maerchenfeeimgarten. codeberg. page/ AntiBillard /@test_004/ [I cannot post links to this host, so I am applying a workround]).

The crash does appear if and only if the computer is playing in an strenght better than “very very weak”. While thinking, the computer will clone the billard table several times, start some random moves and do evolution on the ranked results: If the evolution algorithm is deleting all the testing boards and start a new generation of tests with values based on recombination and mutation of the ranked results of the last generation - it crashes and produces the following output:

index.js:459 Godot Engine v4.4.1.stable.official.49a5bc7b6 - https://godotengine.org
index.js:459 OpenGL API OpenGL ES 3.0 (WebGL 2.0 (OpenGL ES 3.0 Chromium)) - Compatibility - Using Device: WebKit - WebKit WebGL
index.js:459 Current player: b (yellow, full colored balls).
index.js:459 Current player: a (red, half colored balls).
index.js:459 Computer ist dran: 3
index.js:459 Gewinner ist: x: 0.088115490973 y: 0.97361129522324
index.js:474 ERROR: Parameter "mem" is null.
onPrintError @ index.js:474
index.js:474    at: alloc_static (core/os/memory.cpp:108)
onPrintError @ index.js:474
index.js:474 ERROR: Parameter "mem_new" is null.
onPrintError @ index.js:474
index.js:474    at: resize (./core/templates/cowdata.h:369)
onPrintError @ index.js:474
index.js:9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x28652b
    at 0c6d89be:0x109b9e4
    at 0c6d89be:0x289e684
    at 0c6d89be:0x2af55f1
    at 0c6d89be:0x2af43bf
    at 0c6d89be:0x8dda5f
    at 0c6d89be:0xb2f64
    at 0c6d89be:0x2ab970
    at 0c6d89be:0x126bf35
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8acbf6 Uncaught RuntimeError: memory access out of bounds
    at 0c6d89be:0x8acbf6
    at 0c6d89be:0x2da6d81
    at send (index.js:9:167661)
    at RingBuffer.consumed (index.js:9:168450)
    at node.port.onmessage (index.js:9:168929)
0c6d89be:0x8878e Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x8878e
    at 0c6d89be:0x2bc455d
    at HTMLCanvasElement.<anonymous> (index.js:9:180921)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)
0c6d89be:0x46fd9 Uncaught RuntimeError: null function or function signature mismatch
    at 0c6d89be:0x46fd9
    at 0c6d89be:0x47138
    at 0c6d89be:0x66f88
    at 0c6d89be:0x50b0b0
    at 0c6d89be:0x2c94453
    at move_cb (index.js:9:199850)


index.js:459 Gewinner ist: indicates the fittest member of the current generation is found and a new one is starting.

The evolution algorithm could be found in the file AntiBillard/src/branch/main/Scripte/queue.gd

My old exports (verison 0.0.5 of my game) is working and does not crash. It was build with v4.3.stable.official.77dcf97d8

Edit: You can get the soure code for testing purpose hosted on Codeberg, user “MaerchenfeeimGarten”, project “AntiBillard”. (I cannot post the link so this is another workaround saying how you can find it yourself.)

Ok, I could solve the problem by myself:

The main cause was a loop that took a very long time causing the game not responding to any input. If I add

await get_tree().create_timer(1.0/50.0).timeout 

to each iteration of the loop, the game is still responding (desktop and html) and the html export does not crash anymore. The error messages (see last post) are gone.

I had to disable the execution of _process(delta) while running that loop to prevent undefined behavior because while running the await method, without any changes to _process(delta) it will be executed several times in between of the code of the loop.