|
themish
|
 |
« on: 05. February 2010, 04:02:57 pm » |
|
Hi, I'm using a modified test launcher (as in the xith-tk) to launch different configurations of my application. But when I launch the same setting twice in a row, I get this exception: java.lang.NullPointerException at org.xith3d.scenegraph.TextureImage2D.getData(TextureImage2D.java:176) at org.xith3d.render.jsr231.TextureUnitStateUnitPeer.defineTexture(TextureUnitStateUnitPeer.java:323) at org.xith3d.render.jsr231.TextureUnitStateUnitPeer.bindTexture(TextureUnitStateUnitPeer.java:573) at org.xith3d.render.jsr231.TextureUnitStateUnitPeer.setTextureState(TextureUnitStateUnitPeer.java:583) at org.xith3d.render.jsr231.TextureUnitStateUnitPeer.apply(TextureUnitStateUnitPeer.java:1066) at org.xith3d.render.RenderPeer.renderAtom(RenderPeer.java:306) at org.xith3d.render.jsr231.RenderPeerImpl.drawBin(RenderPeerImpl.java:382) at org.xith3d.render.jsr231.RenderPeerImpl.renderMain(RenderPeerImpl.java:652) at org.xith3d.render.jsr231.RenderPeerImpl.renderRenderPass(RenderPeerImpl.java:795) at org.xith3d.render.jsr231.RenderPeerImpl.render(RenderPeerImpl.java:888) at org.xith3d.render.jsr231.CanvasPeerImplBase.doRender(CanvasPeerImplBase.java:338) at org.xith3d.render.jsr231.CanvasPeerImplAWT.display(CanvasPeerImplAWT.java:706) at com.sun.opengl.impl.GLDrawableHelper.display(GLDrawableHelper.java:78) at javax.media.opengl.GLCanvas$DisplayAction.run(GLCanvas.java:435) at com.sun.opengl.impl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:194) at javax.media.opengl.GLCanvas$DisplayOnEventDispatchThreadAction.run(GLCanvas.java:452) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199) at java.awt.EventQueue.dispatchEvent(EventQueue.java:597) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) I guess I'm ending the xith rendering wrongly and when the same scene is run again (with the same textures), it doesn't load the textures again and crashes. Do you think its likely? What exactly could be the problem? How to end the xith rendering properly? thanks a lot! Michal
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #1 on: 05. February 2010, 10:48:48 pm » |
|
Simply call renderLoop.end(). Never kill the thread or something like that. The rendering system needs to cleanup resources.
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
themish
|
 |
« Reply #2 on: 08. February 2010, 03:15:54 pm » |
|
Hi, thanks for reply.
I'm extending the InputAdapterRenderLoop (or in fact Xith3DTest)
and to end rendering calling this:
super.setStopOperation( StopOperation.DESTROY ); super.end();
Is it correct? I still get the error, so if this is correct, I don't have a clue what could be wrong.
cheers,
Michal
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #3 on: 08. February 2010, 09:13:34 pm » |
|
Just leave stop operation at its default.
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
themish
|
 |
« Reply #4 on: 09. February 2010, 11:49:40 am » |
|
it does not help. Do you think there can be some other problem?
Michal
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #5 on: 09. February 2010, 06:53:46 pm » |
|
Obviously there is. Could you post something runnable to reproduce the problem?
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
themish
|
 |
« Reply #6 on: 12. February 2010, 04:02:26 pm » |
|
Hi, well I could not isolate the code, so if you'd like to try the whole source code, it's here: http://personal.cis.strath.ac.uk/~michal/files/EM3Dsource.zipJust run the (only) experiment twice (you can end it using the button at bottom right) and the error will appear. Thanks Michal
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #7 on: 12. February 2010, 05:09:05 pm » |
|
I'm sorry. But I don't have time atm. to dig into more code than compact examples. I hope, you understand that.
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
Agrv
|
 |
« Reply #8 on: 12. February 2010, 08:47:16 pm » |
|
Sorry, I tried to launch your program but it triggers almost immediately a NullPointerException. Could you be more precise on what class I have to launch ? Otherwise I will not be able to help you.
|
|
|
|
|
Logged
|
|
|
|
|
themish
|
 |
« Reply #9 on: 15. February 2010, 03:20:24 pm » |
|
Hi,
Marvin: I completely understand that
Argv: Class to launch is org.xith3d.test.Xith3DTestLauncher
Thanks a lot
Michal
|
|
|
|
|
Logged
|
|
|
|
|
Agrv
|
 |
« Reply #10 on: 15. February 2010, 08:57:26 pm » |
|
Marvin, in fact you get the exact same error when launching twice the FirstPersonInputHandlerTest in xith-tk, returning to the launcher between the two tests.
I am still digging into it, it seems on the second pass the TextureImage2D.getDataBuffer() returns null, maybe the TextureLoader still relies on buffers that have been destroyed or something like this.
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #11 on: 16. February 2010, 06:28:50 pm » |
|
I have fixed that. The problem was, that the texture cache had to be cleared when the xith3denvironment is destroyed.
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
Agrv
|
 |
« Reply #12 on: 16. February 2010, 10:41:48 pm » |
|
Thanks Marvin, this corrects the problem for the FirstPersonInputHandlerTest.
Sadly it is still present for Themish's example, although the destroy method is effectively called and the textureloaders's cache cleared. I will see what other reasons exist for a TextureImage2D having a null databuffer.
|
|
|
|
|
Logged
|
|
|
|
Marvin Fröhlich
Xith Lord
Administrator
Guru
   
Offline
Posts: 4381
May the 4th, be with you...
|
 |
« Reply #13 on: 17. February 2010, 10:09:05 am » |
|
Check, if any textures are kept in a cache or static field or something like that. After the resources have been destroyed, a texture must not be reused. Well, I could check, if this can be changed. But for now this is the reason, why Thremish's example will fail.
Marvin
|
|
|
|
|
Logged
|
|
|
|
|
Agrv
|
 |
« Reply #14 on: 18. February 2010, 08:38:06 am » |
|
Good catch, it is the fallback texture which is kept in a static field in TextureLoader. Adding this on line 121 fixes it : if ( fallbackTexture == null || fallbackTexture.getImage( 0 ).getDataBuffer() == null ) Maybe you will find a better fix so I have not commited it yet. EDIT : I have commited the fix in the SVN repository.
|
|
|
|
« Last Edit: 20. February 2010, 10:17:11 pm by Agrv »
|
Logged
|
|
|
|
|