www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: raft on December 17, 2010, 03:44:15 am

Title: NPE, what is null here?
Post by: raft on December 17, 2010, 03:44:15 am
this sometimes happes when i press home button. not sure what is null here?

Code: [Select]
java.lang.NullPointerException
  at com.threed.jpct.GLRenderer.blit(GLRenderer.java:1252)
  at com.threed.jpct.GLRenderer.execute(GLRenderer.java:1668)
  at com.threed.jpct.FrameBuffer.blit(FrameBuffer.java:594)
  at raft.glgui.android.TexturePack.blit(TexturePack.java:259)
 ..
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 07:42:13 am
Maybe the texture to blit? I'm not sure if i'm looking at the latest sources right now...i'll look at this in more detail when i get home.
Title: Re: NPE, what is null here?
Post by: raft on December 17, 2010, 02:37:17 pm
i dont think so. once packed, texture is never nullified in TexturePack.
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 06:29:05 pm
But it has to. This is the code at that line:

Code: [Select]
float h = (float) t.getHeight();

where t is the texture that is directly feed into the method from the FrameBuffer's blit-method. However, some dispose or remove-methods clear that reference when executed in another thread, especially when finalizing the framebuffer. Might be that the old framebuffer get's finalized and that triggers the clear process...i'll see what to do to fix this...
Title: Re: NPE, what is null here?
Post by: raft on December 17, 2010, 06:37:25 pm
mm, there is a call to FrameBuffer.freeMemory() in my onPause() and onStop() methods, that may be the cause (they are executed in gui thread)
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 08:14:49 pm
Might be, but my clear logic was flawed anyway. It might be better now, please give the new jar a try: http://www.jpct.net/jpct-ae/download/alpha/jpct_ae.jar (http://www.jpct.net/jpct-ae/download/alpha/jpct_ae.jar)
Title: Re: NPE, what is null here?
Post by: raft on December 17, 2010, 08:27:12 pm
after a few tries, i've got another NPE:

Code: [Select]
java.lang.NullPointerException
  at com.threed.jpct.Interact2D.reproject2D3DBlit(Interact2D.java:269)
  at com.threed.jpct.GLRenderer.blit(GLRenderer.java:1312)
  at com.threed.jpct.GLRenderer.execute(GLRenderer.java:1668)
  at com.threed.jpct.FrameBuffer.blit(FrameBuffer.java:594)
  at raft.glgui.android.TexturePack.blit(TexturePack.java:259)
        ...
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 08:29:54 pm
That can only happen, if the FrameBuffer given to that method is null.
Title: Re: NPE, what is null here?
Post by: raft on December 17, 2010, 08:49:05 pm
are you sure? i've put a try catch around that block, catch NPE and print buffer, it seems not null ???

btw, other NPE seems to be gone ;D
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 08:55:27 pm
Yes, i'm sure...but i wasn't aware that i'm calling this method... ;D The problem seems to be, that the blitting happens in parallel with your freeMemory()-call. I can't really handle this 100%. I've uploaded a new jar that tries to, but there's still room for failure. Can you synchronize the freeMemory call somehow?
Title: Re: NPE, what is null here?
Post by: raft on December 17, 2010, 09:02:21 pm
i dont get it. freeMemory() call cannot set my FrameBuffer to null, which you say certainly is null.

i'm trying to avoid synchronized blocks but i can try some othe kind of synchronization.
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 09:05:34 pm
It's a bit complicated. AE uses some static Object arrays to store data, like the the data that is passed down to the renderer for blitting. These buffers need some cleanup from time to time or otherwise. they'll keep references to unused objects for ever. freeMemory() removes references to the frame buffer from these buffers but if the renderer tries to blit that thing on this moment, it get null instead of the (now invalid) buffer.
Title: Re: NPE, what is null here?
Post by: raft on December 17, 2010, 09:15:06 pm
i see. so i dont pass a null buffer but an invalidate buffer.

btw, i see some "All texture data unloaded from gpu!" logs, is this done at freeMemory() ?
Title: Re: NPE, what is null here?
Post by: EgonOlsen on December 17, 2010, 09:17:21 pm
Yes, it is.