jPCT-AE - a 3d engine for Android => Support => Topic started by: raft on March 23, 2013, 06:04:49 pm

Title: exception in Object3D.rotateMesh on OUYA
Post by: raft on March 23, 2013, 06:04:49 pm
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.

Code: [Select]
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:

Code: [Select]
   public Particle() {
      super(PLANE, true);

kind of urgent, OUYA will be launched for backers on 28 march ::)
Title: Re: exception in Object3D.rotateMesh on OUYA
Post by: paulscode on March 23, 2013, 07:50:36 pm
Here are a couple more stack traces I got that were slightly different:

Code: [Select]
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)

Code: [Select]
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)
Title: Re: exception in Object3D.rotateMesh on OUYA
Post by: EgonOlsen on March 23, 2013, 08:47:35 pm
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 (http://jpct.de/download/beta/jpct_ae.jar)
Title: Re: exception in Object3D.rotateMesh on OUYA
Post by: raft on March 23, 2013, 11:37:56 pm
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:

Code: [Select]
loading level: xx
without either one of these in between

Code: [Select]
level loaded: xx
Code: [Select]
load level failed. level: xx
Title: Re: exception in Object3D.rotateMesh on OUYA
Post by: EgonOlsen on March 26, 2013, 11:20:09 pm
Has this issue been resolved?
Title: Re: exception in Object3D.rotateMesh on OUYA
Post by: raft on March 26, 2013, 11:28:46 pm
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..