Iron not found

So new to Armory and I’m trying to get cloth physics to work. upon compileing i get this error on repeat:

Trace: ReferenceError: iron is not defined
    at print (<anonymous>:1324:29)
    at la (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:289:81)
    at Fa (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:18:38)
    at A (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:32:25)
    at <anonymous>:wasm-function[122]:0xbdb7
    at $v (<anonymous>:wasm-function[27]:0x458b)
    at <anonymous>:wasm-function[288]:0x22d48
    at th (<anonymous>:wasm-function[1155]:0x90a3a)
    at b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_2 (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:121:483)
    at new ez (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:447:306)

Any ideas/tutorials on how to fix this?

Hi and welcome :slight_smile:

This is quite an unusual error message, so I’m not exactly sure what’s causing this. I was able to reproduce the error in the physics_softbody example when running it in the examples browser but when running it locally I get different errors, on Krom it directly runs out of memory and on html5 it simply freezes without any error message. So something is definitely wrong here…

If it is ok for you, could you please share the file that causes the error for you? Also, do you run the game in Krom or with html5?

I’m using Krom. The file is also a fresh blender. the only thing changed is the cube was replaced with a flat plane and cloth physics was turned on. I was also able to grab the console errors at the start of the run.

Armory v2022.10 ($Id: 5c879f12ddbcfaa7f39e4c5bd16720f4a5d6eceb $)
Saved: 'C:\Users\david\Documents\Blender\Game\build_cloth_test\compiled\Assets\envmaps\env_World.jpg'
 Time: 00:00.40 (Saving: 00:00.00)

CMFT info: Converting latlong image to cubemap.
CMFT info: Saving spherical harmonics coefficients to C:\Users\david\Documents\Blender\Game\build_cloth_test/compiled/Assets/envmaps/env_World_irradiance.c
CMFT info: Done.
#512x256
#256x128
#128x64
#64x32
#32x16
#16x8
#8x4
#4x2
#2x1
#1x1
Exporting Scene
Scene exported in 0.006s
Finished in 4.684s
Initializing a new default audio device.
Trace: ReferenceError: iron is not defined
    at print (<anonymous>:1324:29)
    at la (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:289:81)
    at Fa (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:18:38)
    at A (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:32:25)
    at <anonymous>:wasm-function[122]:0xbdb7
    at $v (<anonymous>:wasm-function[27]:0x458b)
    at fq (<anonymous>:wasm-function[1018]:0x897ac)
    at b._emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5 (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:220:509)
    at yz.CreateFromTriMesh (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:586:304)
    at armory_trait_physics_bullet_SoftBody.init (<anonymous>:6380:60)
Trace: TypeError: Cannot read property 'get_m_nodes' of null
    at armory_trait_physics_bullet_PhysicsHook.init (<anonymous>:4869:24)
    at render (<anonymous>:7758:6)
    at Function.render (<anonymous>:28600:4)
    at renderCallback (<anonymous>:28743:14)

sadly since I’m a new user i cant post the blend file.

Thanks! I’m able to confirm the issue, I will look into it :slight_smile:

Sorry for the necro, but any updates on what’s going on?

Hi, sorry for my late answer, I’ve been quite busy over the last days. I was able to find the cause for that specific error message (“iron is not defined”), but unfortunately things seem to be a bit more complicated and your error message happens within another error: for physics, we use ammo.js on some targets, and for some reason ammo.js runs out of memory. When it tries to inform the user about this problem, it needs to call a function from Iron to print the error message to the console and it cannot find that function, so a new error occurs (the one you are experiencing).

Fixing the second error (i.e. accessing Iron) is relatively easy, but I’m not quite sure what to do about the original error. If you want to see the original error message yourself, just enable the debug console. It will probably look like this:

Sources/armory/trait/internal/Bridge.hx:16: Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 67108864, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0
Trace: Uncaught abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value 67108864, (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 "). Build with -s ASSERTIONS=1 for more info.

@QuantumCoderQC Sorry about the ping, maybe you know more about this by any chance? Do we need to rebuild ammo.js with a larger/dynamic memory size or does it look like some problem with the Armory code that’s allocating more memory than needed? The current memory size already looks quite big (the issue can be reproduced in a file with just a single plane(!)) and I’m wondering why this issue didn’t happen before… There is no stack trace in the actual error message but it happens at the same place than the error in the first post above (in the call to helpers.CreateFromTriMesh() in SoftBody.init()).

2 Likes

Any fixes yet? or any way to work around the issue?

Sorry, I don’t think there is a fix or workaround at the moment (unless you want to recompile ammo.js).

I personally don’t know much about ammo.js and Bullet physics, and I’m not really sure how to solve this issue since I’m wondering whether there might be some hidden problem leading to this error message (as I wrote above). @ QuantumCoderQC might know more about this, but I think he is quite busy at the moment. If you want to make sure that this problem isn’t forgotten, please open an issue for this. Please let me know if you don’t have a GitHub account, then I can create the issue tomorrow.

Just posted the error report. thankfully the iron error got fixed so the error is now more clear

Trace: RuntimeError: memory access out of bounds
    at fq (<anonymous>:wasm-function[1018]:0x897e1)
    at b._emscripten_bind_btSoftBodyHelpers_CreateFromTriMesh_5 (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:220:509)
    at yz.CreateFromTriMesh (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:586:304)
    at armory_trait_physics_bullet_SoftBody.init (<anonymous>:7092:60)
    at update (<anonymous>:8421:7)
    at kha_TimeTask.task (<anonymous>:29083:4)
    at Function.executeTimeTasks (<anonymous>:28966:76)
    at Function.executeFrame (<anonymous>:28916:18)
    at renderCallback (<anonymous>:29743:17)
Trace: RuntimeError: memory access out of bounds
    at $v (<anonymous>:wasm-function[27]:0x42ad)
    at <anonymous>:wasm-function[288]:0x22d48
    at th (<anonymous>:wasm-function[1155]:0x90a3a)
    at b._emscripten_bind_btDefaultMotionState_btDefaultMotionState_2 (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:121:483)
    at new ez (eval at kha_Assets.loadBlobFromPath.fileName (unknown source), <anonymous>:447:306)
    at armory_trait_physics_bullet_PhysicsHook.init (<anonymous>:5572:22)
    at render (<anonymous>:8470:6)
    at Function.render (<anonymous>:29601:4)
    at renderCallback (<anonymous>:29744:14)

Now we’re getting somewhere.

2 Likes

Hi, thank you for the info and for your patience. The error messages stems from this line:

Specifically, because of the casting from positions: Float32Array and vecind: Uint32Array to haxe.ds.Vector<Float> and haxe.ds.Vector<Int> respectively.

This can be solved by explicitly creating these vectors instead of casing and then passing them to the function. Like so:

...
...
var positionsVector: haxe.ds.Vector<Float> = new haxe.ds.Vector<Float>(positions.length);
for(i in 0...positions.length){
		positionsVector.set(i, positions.get(i));
	}

var vecindVector: haxe.ds.Vector<Int> = new haxe.ds.Vector<Int>(vecind.length);
	for(i in 0...vecind.length){
		vecindVector.set(i, vecind.get(i));
	}

#if js
    body = helpers.CreateFromTriMesh(worldInfo, positionsVector, vecindVector, numtri);
#elseif cpp
...
...

This removes all the runtime errors. However, it still does not completely solve the issue. While the soft body simulation in Bullet Physics Ammo seems correct (verified through tracing out the vertex positions), the vertex positions are not assigned back to the visual mesh properly. This causes the mesh to twitch and cause artefacts. One of the many possible issues is the calculation of the number of vertices here:

If for example the original mesh has 4 vertices, the calculated numVerts is just 2.

I have not explored how to fix the visuals yet, since I am quite busy these days. I could give this another shot, but not soon…

Hope this helps :slightly_smiling_face:

Best,
QC

So any updates? I cant seem to still solve the problem…

Hi, I am currently working on fixing the issue. I already have a fix for it, and the community is testing it. In case you would like to try it for yourself, here are the changes:

You need to replace both iron and armory repos. I will push the fix after a few more tests.

BTW, if you didn’t know already, there is more community interaction over on Armory3D discord than here. So, feel free to join :slightly_smiling_face:

3 Likes