From 3bd82be0371e40390abc5509cb2a7d6e3a055a12 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Thu, 12 Jan 2012 19:57:01 -0800 Subject: j3dcore: use consistent locking when updating the renderAtoms array You cannot lock updates to a member variable using itself if the reference is ever changed. The renderAtoms array in GeomtryAtom is resized when it does not have enough room for all the open views. This leads to crashes similar to the following: Exception in thread "J3D-RenderStructureUpdateThread-5" java.lang.ArrayIndexOutOfBoundsException: 3 at javax.media.j3d.GeometryAtom.getRenderAtom(GeometryAtom.java:241) at javax.media.j3d.RenderBin.processTransformChanged(RenderBin.java:3506) at javax.media.j3d.RenderBin.processMessages(RenderBin.java:1772) at javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.java:102) at javax.media.j3d.J3dThread.run(J3dThread.java:275) Use the existing lockObj in this class to synchronize access. This lock is already being used to protect updates to the centroid update calculation, but both locked sections are relatively short, if contention ends up being a problem, renderAtoms could be changed to an ArrayList instead which can be resized. Signed-off-by: Harvey Harrison --- src/classes/share/javax/media/j3d/GeometryAtom.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/classes') diff --git a/src/classes/share/javax/media/j3d/GeometryAtom.java b/src/classes/share/javax/media/j3d/GeometryAtom.java index ce67bd7..d49040d 100644 --- a/src/classes/share/javax/media/j3d/GeometryAtom.java +++ b/src/classes/share/javax/media/j3d/GeometryAtom.java @@ -164,7 +164,7 @@ class GeometryAtom extends Object implements BHLeafInterface, NnuId { // If renderAtom is not scoped to this view, don't even // bother creating the renderAtom - synchronized (renderAtoms) { + synchronized (lockObj) { index = view.viewIndex; if (index >= renderAtoms.length) { @@ -236,9 +236,8 @@ class GeometryAtom extends Object implements BHLeafInterface, NnuId { } } } + return (renderAtoms[index]); } - - return (renderAtoms[index]); } // If the renderAtom is transparent, then make sure that the // value is up-to-date -- cgit v1.2.3