Print

Print


That's an incredibly irritating exception.  Can you provide us with  
some simple code that does it repeatably?

Here's the problem.  In NetworkPortrayal3D.updateModel, the  
pseudocode looks like this:

	for i = NumNodesInModel - 1 ; i >= 0 ; i--
		if node[i] passes a certain test
			fiddle with node[i]
		else
			remove node[i] from model

Nodes are stored in a TransformGroup, which stores the nodes (its  
"children") as an array.  Removing them slides higher-indexed  
children down the array.  That's why we go backwards through the array.

So here's the weird thing: we requested node[i] to see if it passed  
the test.  At that point, i is a valid index.  Then when we try to  
remove it, suddenly i is no longer a valid index.

I smell a race condition here.  Unfortunately Java3D race conditions  
are Evil.

Will think more deeply on it.  In the meantime, you might be able to  
hack around it by changing line 150 of NetworkPortrayal3D.java from

                 globalTG.removeChild(t);
to
                 try { globalTG.removeChild(t); } catch  
(IndexOutOfBoundsException z) { }

Sean


On Jun 6, 2008, at 4:20 PM, ST Charles, Jesse Lee wrote:

> Sean,
> The 3d network seems to be working much better now, thanks!
> An occasional exception that pops up now (maybe 1 in 10 runs), is
>
>
> java.lang.IndexOutOfBoundsException: Index: 22, Size: 22
> 	at java.util.ArrayList.RangeCheck(Unknown Source)
> 	at java.util.ArrayList.get(Unknown Source)
> 	at
> javax.media.j3d.GroupRetained.removeChild(GroupRetained.java:336)
> 	at javax.media.j3d.Group.removeChild(Group.java:210)
> 	at
> sim.portrayal3d.network.NetworkPortrayal3D.updateModel 
> (NetworkPortrayal3
> D.java:150)
> 	at
> sim.portrayal3d.FieldPortrayal3D.getModel(FieldPortrayal3D.java:182)
> 	at sim.display3d.Display3D.updateSceneGraph(Display3D.java:1161)
> 	at sim.display3d.Display3D.step(Display3D.java:1117)
> 	at sim.display.GUIState$Repeat.step(GUIState.java:606)
> 	at sim.display.GUIState.step(GUIState.java:428)
> 	at sim.display.Console$56.run(Console.java:2277)
> 	at java.lang.Thread.run(Unknown Source)
>
> I'm not sure if this is related to the recent changes to
> NetworkPortrayal3D.java, but I thought I would make you aware of the
> issue.
>
> -Jesse
>
>
>
> -----Original Message-----
> From: MASON Multiagent Simulation Toolkit
> [mailto:[log in to unmask]] On Behalf Of Sean Luke
> Sent: Thursday, June 05, 2008 8:54 PM
> To: [log in to unmask]
> Subject: Re: 3d Edge Portrayal Problem
>
> Okay, we've stomped the bug.  It's out on CVS but there's a new
> function that you'll need to call from your setupPortrayals() (or
> start() or load()) method: display.destroySceneGraph().  See any of
> the 3D app example code to see where it goes.  Also the tutorials.
>
> Note that this will work fine with CylinderEdgePortrayal3D and
> SimpleEdgePortrayal3D, but ConeEdgePortrayal3D and
> ArrowEdgePortryal3D still need a tiny bit of work, which should be
> out on CVS by end of tomorrow my guess is.
>
> Sean