NPE, what is null here?

Started by raft, December 17, 2010, 03:44:15 AM

Previous topic - Next topic

raft

this sometimes happes when i press home button. not sure what is null here?

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)
..

EgonOlsen

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.

raft

i dont think so. once packed, texture is never nullified in TexturePack.

EgonOlsen

But it has to. This is the code at that line:


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...

raft

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)

EgonOlsen

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

raft

after a few tries, i've got another NPE:

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)
        ...

EgonOlsen

That can only happen, if the FrameBuffer given to that method is null.

raft

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

EgonOlsen

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?

raft

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.

EgonOlsen

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.

raft

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() ?

EgonOlsen