exception in Object3D.rotateMesh on OUYA

Started by raft, March 23, 2013, 06:04:49 PM

Previous topic - Next topic

raft

this exception newer happens on my Nexus 7, my phone or desktop. two Ouya console owners reported this. and it does not always happen. but once happened, level loading fails until application is restarted, possibly because of same exception.

this code runs during level loading in a background thread.

java.lang.ArrayIndexOutOfBoundsException: length=11; index=11
at com.threed.jpct.Vectors.addVertex(Vectors.java:85)
at com.threed.jpct.Object3D.setBoundingBox(Object3D.java:2507)
at com.threed.jpct.Object3D.calcBoundingBox(Object3D.java:1197)
at com.threed.jpct.Object3D.rotateMesh(Object3D.java:2411)
at raft.jumpy.view.Particle.<init>(Particle.java:66)
at raft.jumpy.view.ParticleManager.<init>(ParticleManager.java:43)
at raft.jumpy.view.GameView.<init>(GameView.java:111)
at raft.jumpy.android.ouya.JumpyActivity$5.run(JumpyActivity.java:522)



and this is the relavant particle class. taken from Robombs code I suppose:

   public Particle() {
      super(PLANE, true);
      rotateZ((float)Math.random()*6f);
      rotateMesh();
      clearRotation();
      setBillboarding(Object3D.BILLBOARDING_ENABLED);
      setVisibility(Object3D.OBJ_VISIBLE);
      setCulling(Object3D.CULLING_DISABLED);
      setAdditionalColor(RGBColor.WHITE);
      setLighting(Object3D.LIGHTING_NO_LIGHTS);
      enableLazyTransformations();
      reset();
      shareCompiledData(PLANE);
      build();
      texture="particle_blast";
   }


kind of urgent, OUYA will be launched for backers on 28 march ::)

paulscode

Here are a couple more stack traces I got that were slightly different:

03-23 18:31:44.762: W/System.err(1291): java.lang.ArrayIndexOutOfBoundsException: length=11; index=12
03-23 18:31:44.762: W/System.err(1291): at com.threed.jpct.Vectors.addVertex(Vectors.java:85)
03-23 18:31:44.762: W/System.err(1291): at com.threed.jpct.Object3D.setBoundingBox(Object3D.java:2513)
03-23 18:31:44.762: W/System.err(1291): at com.threed.jpct.Object3D.calcBoundingBox(Object3D.java:1197)
03-23 18:31:44.762: W/System.err(1291): at com.threed.jpct.Object3D.rotateMesh(Object3D.java:2411)
03-23 18:31:44.762: W/System.err(1291): at raft.jumpy.view.Particle.<init>(Particle.java:66)
03-23 18:31:44.762: W/System.err(1291): at raft.jumpy.view.ParticleManager.<init>(ParticleManager.java:43)
03-23 18:31:44.762: W/System.err(1291): at raft.jumpy.view.GameView.<init>(GameView.java:111)
03-23 18:31:44.762: W/System.err(1291): at raft.jumpy.android.ouya.JumpyActivity$5.run(JumpyActivity.java:522)

(index was 12 instead of the typical 11, in case that's significant)

03-23 18:32:34.692: W/System.err(1291): java.lang.ArrayIndexOutOfBoundsException: length=11; index=11
03-23 18:32:34.692: W/System.err(1291): at com.threed.jpct.Mesh.rotateMesh(Mesh.java:682)
03-23 18:32:34.692: W/System.err(1291): at com.threed.jpct.Object3D.rotateMesh(Object3D.java:2406)
03-23 18:32:34.692: W/System.err(1291): at raft.jumpy.view.Particle.<init>(Particle.java:66)
03-23 18:32:34.692: W/System.err(1291): at raft.jumpy.view.ParticleManager.<init>(ParticleManager.java:43)
03-23 18:32:34.692: W/System.err(1291): at raft.jumpy.view.GameView.<init>(GameView.java:111)
03-23 18:32:34.702: W/System.err(1291): at raft.jumpy.android.ouya.JumpyActivity$5.run(JumpyActivity.java:522)

EgonOlsen

If this happens in a background thread, it's most likely a threading issue. The particles share the same mesh. If multiple threads are adding vertices (by calculating the bounding box) to that shared mesh, something like this may happen. I've updated the jPCT-AE beta with a version that synchronizes this access. Maybe that helps: http://jpct.de/download/beta/jpct_ae.jar

raft

#3
thanks :) I see only one explanation of this, pressing a button via controller somehow creates two events and as a result two threads start to load a level.

paul can you please check the logcat output for a symptom of this, for example consecutive logs like:

loading level: xx

without either one of these in between

level loaded: xx
load level failed. level: xx

EgonOlsen


raft

I just guarded against two simultaneous loading and the problem seems to be gone. after this I've seen some logs which approves two button events actually arrives..