Author Topic: JPCT crashed while debugging  (Read 2828 times)

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
JPCT crashed while debugging
« on: June 14, 2012, 05:24:00 am »
JPCT crashed when I resumed from debugging. Using the current stable version.

Quote
06-14 15:20:35.014: ERROR/AndroidRuntime(32289): FATAL EXCEPTION: GLThread 4465
        java.lang.IndexOutOfBoundsException: Invalid index 5, size is 5
        at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
        at java.util.ArrayList.get(ArrayList.java:304)
        at com.threed.jpct.World.draw(World.java:1319)
        at com.threed.jpct.World.draw(World.java:1074)
        at nz.co.nuffie.android.crichq.threedimensional.World3dBase.renderWorld(World3dBase.java:678)
        at nz.co.nuffie.android.crichq.threedimensional.World3dBase.onDrawFrame(World3dBase.java:732)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1463)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1217)
06-14 15:20:35.022: WARN/ActivityManager(195): Force finishing activity nz.co.nuffie.android.crichq/.threedimensional.OfflineViewWorld3dActivity

Edit: Actually this might be my fault. Looks like it might be a threading issue.

« Last Edit: June 14, 2012, 06:53:55 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11770
    • View Profile
    • http://www.jpct.net
Re: JPCT crashed while debugging
« Reply #1 on: June 14, 2012, 08:20:41 am »
This usually happens if you fiddle around with the collection of objects in a world in parallel to the rendering.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: JPCT crashed while debugging
« Reply #2 on: June 18, 2012, 12:15:44 am »
Yeah I was filtering PolyLines on the UI thread. Now fixed, no more crashes now.

I'm wondering if you can add some kind of debug flag so these can be picked up earlier? If the app is on the wrong thread it will crash the app or give a warning.
« Last Edit: June 18, 2012, 12:19:47 am by zammbi »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11770
    • View Profile
    • http://www.jpct.net
Re: JPCT crashed while debugging
« Reply #3 on: June 18, 2012, 08:20:47 am »
I would like to, but it would kill performance. I would have to check for the right thread in almost every method.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: JPCT crashed while debugging
« Reply #4 on: June 18, 2012, 09:02:56 am »
If its a debug flag(default off) I don't see the problem?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11770
    • View Profile
    • http://www.jpct.net
Re: JPCT crashed while debugging
« Reply #5 on: June 18, 2012, 10:01:35 am »
It's still either a method call or at least an if to detect the debug state. It wouldn't matter on the desktop, but it will on Dalvik. Dalvik is still bad at calling methods and can't inline anything.

Offline zammbi

  • float
  • ****
  • Posts: 360
    • View Profile
Re: JPCT crashed while debugging
« Reply #6 on: June 18, 2012, 10:21:30 am »
One boolean check extra per method is going to see a drop in performance? Couldn't you could leave out sensitive methods? Some would be better then nothing.
As for slow debugging I wouldn't mind, I just want to do a test every once and a while.
But I guess if it hurts the engine too much then yeah, I can live without it.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11770
    • View Profile
    • http://www.jpct.net
Re: JPCT crashed while debugging
« Reply #7 on: June 18, 2012, 11:41:56 pm »
The other problem (apart from the performance drop) is, that it might be totally legal to call methods from other threads. Either if you synchronize the calls or if you call them on completely different objects. It doesn't hurt to fiddle around with objects that are not part of the world to prepare them for being added, for example. I don't think that i want to remove this option by forcing a one-thread policy. jPCT-AE is very much like Swing in this regard.