Author Topic: Random crash  (Read 3009 times)

Offline LowPolyMan

  • byte
  • *
  • Posts: 25
    • View Profile
Random crash
« on: March 17, 2013, 02:07:42 am »
Hi There i'm new to this forum, i have some experience in 3d libs on other platforms for few years.
I like this lib a lot, but the documentation and examples could be a lot better..

My problem, i am playing around extending the hello world example, now add a terrain and fog and parent some primitives nothing more nothing less, when i start the app using eclipse and debugging it runs fine, when i start the app on the phone it runs fine also but when i quit and start it again it mostly crashes. After that it runs fine again for mostly 1 time and then crashes again etc .....

There's something i prob. have to unload or clear or something on exit. Hope someone can help me out here ..

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Random crash
« Reply #1 on: March 17, 2013, 01:52:31 pm »
Posting the actual exception will help...

Offline LowPolyMan

  • byte
  • *
  • Posts: 25
    • View Profile
Re: Random crash
« Reply #2 on: March 17, 2013, 09:57:37 pm »
Posting the actual exception will help...

It seems the texture 'launcher' is already loaded sometimes when started again:

03-17 21:54:11.705: E/AndroidRuntime(5916): FATAL EXCEPTION: GLThread 70751
03-17 21:54:11.705: E/AndroidRuntime(5916): java.lang.RuntimeException: [ 1363553651668 ] - ERROR: A texture with the name 'launcher' has been declared twice!
03-17 21:54:11.705: E/AndroidRuntime(5916):    at com.threed.jpct.Logger.log(Logger.java:189)
03-17 21:54:11.705: E/AndroidRuntime(5916):    at com.threed.jpct.TextureManager.addTexture(TextureManager.java:138)
03-17 21:54:11.705: E/AndroidRuntime(5916):    at com.example.tanktest.Tanktest$MyRenderer.onSurfaceChanged(Tanktest.java:265)
03-17 21:54:11.705: E/AndroidRuntime(5916):    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
03-17 21:54:11.705: E/AndroidRuntime(5916):    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
03-17 21:54:11.755: E/android.os.Debug(2267): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Random crash
« Reply #3 on: March 18, 2013, 09:22:31 pm »
Try something like synchronizing that part. Android's life cycle management can be really painful and if this happens at random, it's most likely that onSurfaceChanged will called multiple times for one start/resume. That's not a problem of the engine, your code somehow has to deal with that and how you are doing this, highly depends on your code, so it's hard to give a general advise.
Personally, i don't free/dispose or reload anything. I load everything once at the first start-up and use it from then just like HelloWorld does.

Offline LowPolyMan

  • byte
  • *
  • Posts: 25
    • View Profile
Re: Random crash
« Reply #4 on: March 21, 2013, 04:32:08 pm »
Try something like synchronizing that part. Android's life cycle management can be really painful and if this happens at random, it's most likely that onSurfaceChanged will called multiple times for one start/resume. That's not a problem of the engine, your code somehow has to deal with that and how you are doing this, highly depends on your code, so it's hard to give a general advise.
Personally, i don't free/dispose or reload anything. I load everything once at the first start-up and use it from then just like HelloWorld does.

Thinking that it was smart to do, i put all the 3D related variable in the GLSurfaceView class. This is what crashed the app when restarted. I put all the variable to the main class and now the app restarts at the point where it was stopped and doesn't need to reload / init all objects and textures.

So isn't it possible to realy quit JPCT apps and free all memory?


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Random crash
« Reply #5 on: March 21, 2013, 08:55:54 pm »
A call like

Code: [Select]
System.exit(0);

will kill the VM and terminate the Activity.

Offline LowPolyMan

  • byte
  • *
  • Posts: 25
    • View Profile
Re: Random crash
« Reply #6 on: March 21, 2013, 09:12:57 pm »
A call like

Code: [Select]
System.exit(0);

will kill the VM and terminate the Activity.

I feel so stupid.. TNX!
 ;D