Repository: godot
Issue: Bullet throws "RuntimeError: Index out of bounds" errors in HTML5 export
Labels: bug,platform:web,topic:physics,needs testing,topic:dotnet,topic:3d,topic:export

### Godot version

3.4.4

### System information

Windows 10, GLES2/3, Intel HD Graphics 520

### Issue description

I am trying to display a three-dimensional graph with nodes and edges in an HTML5 export. Both the information of the nodes and the information of the edges are loaded by API calls. The nodes of the graph are StaticBodies because I need collisions and the edges are ArrayMeshes. The camera has an Area to trigger collisions with the nodes, to then make an API call for the edges, and a mouse click fires a raycast,to collides with a node and to fire another API call. When I export my project as a desktop application, calling the API and rendering the nodes or edges works as desired. As soon as I make an HTML5 export and try it out, after some time I get (sometimes faster, sometimes it takes a while) one of the following unknown errors:

<details>
  <summary>RuntimeError: index out of bounds,CollisionObjectBullet</summary>
  
  ```
exception thrown: RuntimeError: index out of bounds,CollisionObjectBullet::set_transform(Transform const&)@:wasm-function[13130]:0x2645dd
RigidBodyBullet::set_state(PhysicsServer::BodyState, Variant const&)@:wasm-function[18505]:0x37ccbd
BulletPhysicsServer::body_set_state(RID, PhysicsServer::BodyState, Variant const&)@:wasm-function[70593]:0xe78e6f
CollisionObject::_notification(int)@:wasm-function[24736]:0x4468b5
CollisionObject::_notificationv(int, bool)@:wasm-function[9051]:0x1b5221
PhysicsBody::_notificationv(int, bool)@:wasm-function[5767]:0x12ad8d
StaticBody::_notificationv(int, bool)@:wasm-function[10911]:0x20afc3
Object::notification(int, bool)@:wasm-function[1145]:0x49309
SceneTree::flush_transform_notifications()@:wasm-function[6651]:0x150c76
SceneTree::idle(float)@:wasm-function[43693]:0xa03999
Main::iteration()@:wasm-function[65648]:0xd309cd
OS_JavaScript::main_loop_iterate()@:wasm-function[48464]:0xb1e37f
main_loop_callback()@:wasm-function[15195]:0x2c1fd2
wasm_invoke_v@:wasm-function[25734]:0x47c995
```
</details>

<details>
  <summary>RuntimeError: index out of bounds,mono_metadata_type_hash</summary>
  
  ```
exception thrown: RuntimeError: index out of bounds,mono_metadata_type_hash@:wasm-function[3225]:0x97e8d
mono_metadata_generic_inst_hash@:wasm-function[7496]:0x170d00
mono_metadata_generic_context_hash@:wasm-function[9731]:0x1d0a25
mono_generic_class_hash@:wasm-function[9780]:0x1d26cc
mono_metadata_type_hash@:wasm-function[3225]:0x97edd
mono_metadata_generic_inst_hash@:wasm-function[7496]:0x170d00
mono_metadata_generic_context_hash@:wasm-function[9731]:0x1d0a25
mono_generic_class_hash@:wasm-function[9780]:0x1d26cc
rehash_table.1@:wasm-function[29686]:0x69e1ab
check_table_size.1@:wasm-function[10106]:0x1e4dcc
mono_conc_hashtable_insert@:wasm-function[6264]:0x13cb9c
mono_metadata_lookup_generic_class@:wasm-function[4787]:0xf18cd
mono_class_bind_generic_parameters@:wasm-function[5452]:0x119c9d
mono_reflection_bind_generic_parameters@:wasm-function[9682]:0x1cf203
ves_icall_RuntimeType_MakeGenericType@:wasm-function[28546]:0x667b00
ves_icall_RuntimeType_MakeGenericType_raw@:wasm-function[28545]:0x667a10
do_icall@:wasm-function[34892]:0x7ea7e9
do_icall_wrapper@:wasm-function[10061]:0x1e1030
interp_exec_method_full@:wasm-function[4369]:0xd4449
interp_exec_method_call_vararg@:wasm-function[9940]:0x1da179
interp_exec_method_full@:wasm-function[4369]:0xd9849
interp_runtime_invoke@:wasm-function[31789]:0x73dca5
mono_jit_runtime_invoke@:wasm-function[30996]:0x7090ec
do_runtime_invoke@:wasm-function[7713]:0x17bb74
mono_runtime_try_invoke@:wasm-function[2552]:0x80c44
mono_runtime_try_invoke_array@:wasm-function[7474]:0x16f2ea
mono_runtime_invoke_array@:wasm-function[30670]:0x6fa570
GDMonoUtils::runtime_invoke_array(_MonoMethod*, void*, _MonoArray*, _MonoException**)@:wasm-function[24208]:0x42a3b5
GDMonoMethod::invoke(_MonoObject*, Variant const**, _MonoException**)@:wasm-function[5982]:0x1327ac
CSharpInstance::call(StringName const&, Variant const**, int, Variant::CallError&)@:wasm-function[70257]:0xe5a1ee
Object::call(StringName const&, Variant const**, int, Variant::CallError&)@:wasm-function[8434]:0x1a2002
Object::emit_signal(StringName const&, Variant const**, int)@:wasm-function[11511]:0x22fe85
Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&)@:wasm-function[791]:0x35928
HTTPRequest::_request_done(int, int, PoolVector<String> const&, PoolVector<unsigned char> const&)@:wasm-function[67328]:0xd865e6
MethodBind4<int, int, PoolVector<String> const&, PoolVector<unsigned char> const&>::call(Object*, Variant const**, int, Variant::CallError&)@:wasm-function[50056]:0xb843ae
Object::call(StringName const&, Variant const**, int, Variant::CallError&)@:wasm-function[8434]:0x1a2092
MessageQueue::_call_function(Object*, StringName const&, Variant const*, int, bool)@:wasm-function[64686]:0xcf1c7a
MessageQueue::flush()@:wasm-function[4593]:0xea165
SceneTree::idle(float)@:wasm-function[43694]:0xa03a85
Main::iteration()@:wasm-function[65650]:0xd31127
OS_JavaScript::main_loop_iterate()@:wasm-function[48465]:0xb1ea89
main_loop_callback()@:wasm-function[15197]:0x2c21f2
wasm_invoke_v@:wasm-function[25735]:0x47cacb
```
</details>

<details>
  <summary>RuntimeError: index out of bounds,mono_metadata_generic_context_hash</summary>
  
  ```
exception thrown: RuntimeError: index out of bounds,mono_metadata_generic_context_hash@:wasm-function[9731]:0x1d0a1a
inflated_signature_hash@:wasm-function[31904]:0x7444a9
do_rehash.1@:wasm-function[34886]:0x7ea0f0
rehash.2@:wasm-function[9503]:0x1c5d85
monoeg_g_hash_table_insert_replace@:wasm-function[973]:0x3dab8
mono_metadata_get_inflated_signature@:wasm-function[14792]:0x2ad86e
mono_inflate_generic_signature@:wasm-function[9756]:0x1d15f6
interp_transform_call@:wasm-function[6303]:0x13edc9
generate_code@:wasm-function[15439]:0x2cff7f
generate@:wasm-function[34532]:0x7c8343
mono_interp_transform_method@:wasm-function[7522]:0x171cc7
do_transform_method@:wasm-function[7712]:0x17bb11
interp_exec_method_full@:wasm-function[4369]:0xd4874
interp_exec_method_call_vararg@:wasm-function[9940]:0x1da179
interp_exec_method_full@:wasm-function[4369]:0xd9849
interp_runtime_invoke@:wasm-function[31789]:0x73dca5
mono_jit_runtime_invoke@:wasm-function[30996]:0x7090ec
do_runtime_invoke@:wasm-function[7713]:0x17bb74
mono_runtime_try_invoke@:wasm-function[2552]:0x80c44
mono_runtime_try_invoke_array@:wasm-function[7474]:0x16f2ea
mono_runtime_invoke_array@:wasm-function[30670]:0x6fa570
GDMonoUtils::runtime_invoke_array(_MonoMethod*, void*, _MonoArray*, _MonoException**)@:wasm-function[24208]:0x42a3b5
GDMonoMethod::invoke(_MonoObject*, Variant const**, _MonoException**)@:wasm-function[5982]:0x1327ac
CSharpInstance::call(StringName const&, Variant const**, int, Variant::CallError&)@:wasm-function[70257]:0xe5a1ee
Object::call(StringName const&, Variant const**, int, Variant::CallError&)@:wasm-function[8434]:0x1a2002
Object::emit_signal(StringName const&, Variant const**, int)@:wasm-function[11511]:0x22fe85
Object::emit_signal(StringName const&, Variant const&, Variant const&, Variant const&, Variant const&, Variant const&)@:wasm-function[791]:0x35928
HTTPRequest::_request_done(int, int, PoolVector<String> const&, PoolVector<unsigned char> const&)@:wasm-function[67328]:0xd865e6
MethodBind4<int, int, PoolVector<String> const&, PoolVector<unsigned char> const&>::call(Object*, Variant const**, int, Variant::CallError&)@:wasm-function[50056]:0xb843ae
Object::call(StringName const&, Variant const**, int, Variant::CallError&)@:wasm-function[8434]:0x1a2092
MessageQueue::_call_function(Object*, StringName const&, Variant const*, int, bool)@:wasm-function[64686]:0xcf1c7a
MessageQueue::flush()@:wasm-function[4593]:0xea165
SceneTree::idle(float)@:wasm-function[43694]:0xa03a85
Main::iteration()@:wasm-function[65650]:0xd31127
OS_JavaScript::main_loop_iterate()@:wasm-function[48465]:0xb1ea89
main_loop_callback()@:wasm-function[15197]:0x2c21f2
wasm_invoke_v@:wasm-function[25735]:0x47cacb
```
</details>

I tried a few things, like disabling collisions, loading only a few nodes and so on, but unfortunately nothing helped. In fact, it seemed to work without error, if I did not initially set a position for the StaticBodies, because I read in the manual that you should not move StaticBodies. Unfortunately, changing StaticBody to RigidBody didn't work either.

### Steps to reproduce

In my project the steps to reproduce the bug are the following:

1. Exporting the projects as a HTML5 build
2. Embedding the project into a web server
3. Starting the Projekt by going to the HTML-Page
4. Waiting for the first API-Calls to execute and waiting for rendering of the graph nodes
5. The IFrame freezes and the error occurs

### Minimal reproduction project

Of couse I will try to build a minimal reproduction project if it is needed, but at the moment i dont even know which part of my code produces the error to be honest and I just wanted to ask if my bug is a known error