June 2008


Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Fri, 6 Jun 2008 16:59:13 -0400
text/plain (87 lines)
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]
			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 from

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


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
> 	at
> 	at
> (NetworkPortrayal3
> 	at
> sim.portrayal3d.FieldPortrayal3D.getModel(
> 	at sim.display3d.Display3D.updateSceneGraph(
> 	at sim.display3d.Display3D.step(
> 	at sim.display.GUIState$Repeat.step(
> 	at sim.display.GUIState.step(
> 	at sim.display.Console$
> 	at Source)
> I'm not sure if this is related to the recent changes to
>, 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