Error while detaching children

Ok I don’t know what is the problem, but I am detaching lots of object 1 by 1 from some node and I get following error:

Exception in thread “LWJGL Renderer Thread” java.lang.IndexOutOfBoundsException: Index: 244, Size: 244

at java.util.ArrayList.RangeCheck(Unknown Source)

at java.util.ArrayList.get(Unknown Source)

at com.jme3.scene.Node.updateGeometricState(

at com.jme3.scene.Node.updateGeometricState(


at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(

at com.jme3.system.lwjgl.LwjglCanvas.runLoop(


at Source)

Any ideas why? :slight_smile:

Here’s the relevant code:

for (int i = 0, cSize = children.size(); i < cSize; i++) {

Spatial child = children.get(i);



There’s only one explanation: You’re detaching things outside the render thread :stuck_out_tongue:

You might be right. I am rendering in AWT canvas (based on TestCanvas), and I detach or attach children to my nodes, based on what user clicks in a Swing window. Till now I didn’t have any problems while testing (found out that it only happens when lots of children is detached). Any ideas how to overcome this? :slight_smile:

Its similar to using the AWT event queue, you create a Callable that is executed on the opengl thread. I posted an example snippet here.



Thats cool, thanks! :slight_smile: