Rev.1256 - Rev.1267 Some null point exceptions in box2d

Anything libgdx related goes here!

Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby gamefish » Tue Dec 28, 2010 8:37 am

Hey guys:
After I updated to Rev.1267, my game encounters some null point exceptions about Contact in Box2d logic, in desktop version(haven't try out android version yet).
So I switched back to Rev.1256. and everything is fine again.
Since I'm extremely slow when visiting the svn here from China, I can't change revisions quickly and can't find what is going on. And I haven't run the Box2D tests with the latest revision yet.

Is there anybody encountered the same problem?
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby NateS » Tue Dec 28, 2010 10:32 am

Please post the exception.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby gamefish » Tue Dec 28, 2010 2:53 pm

Here are 2 exceptions. A contact is generated but later when the logic try to get fixtureA and fixtureB of the contact, one of them is null.
---------------------------------Exception 1------------------------------------------------------------
Exception in thread "LWJGL Application" java.lang.NullPointerException
at com.badlogic.gdx.physics.box2d.World.contactFilter(World.java:506)
at com.badlogic.gdx.physics.box2d.World.jniStep(Native Method)
at com.badlogic.gdx.physics.box2d.World.step(World.java:296)
at com.html5game.tank.states.GameLevel.updateGame(GameLevel.java:373)

---------------------------------Exception 2------------------------------------------------------------
Exception in thread "LWJGL Application" java.lang.NullPointerException
at com.html5game.tank.states.GameLevel.beginContact(GameLevel.java:661)
at com.badlogic.gdx.physics.box2d.World.beginContact(World.java:521)
at com.badlogic.gdx.physics.box2d.World.jniStep(Native Method)
at com.badlogic.gdx.physics.box2d.World.step(World.java:296)
at com.html5game.tank.states.GameLevel.updateGame(GameLevel.java:373)

Below is my code that caused this exception, either getFixtureA or getFixtureB will return null.
Code: Select all
@Override
    public void beginContact(Contact contact)
    {
   Body a = contact.getFixtureA().getBody();
   Body b = contact.getFixtureB().getBody();
    }

-----------------------------------------------------------------------------------

I tried all the box2d tests and the pinball demo, everything is fine.
I suppose this is because I called world.destroyBody() function to erased some useless bodies. But this is fine in the older revision.
I noticed in world.java, LongHashMap is replaced by LongMap, can this be the reason that caused some chaos in contact mapping?
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby mzechner » Tue Dec 28, 2010 7:43 pm

Hm, Nate did some changes to the utility classes it seems. I got to check it out. When do you destroy your body? You are not allowed to do so in the ContactListener.

If you have a minimal code example for us to reproduce the issue it would of course help as well :)
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby gamefish » Wed Dec 29, 2010 9:18 am

mzechner wrote:Hm, Nate did some changes to the utility classes it seems. I got to check it out. When do you destroy your body? You are not allowed to do so in the ContactListener.

If you have a minimal code example for us to reproduce the issue it would of course help as well :)


Yeah I didn't delete bodies in ContactListener, if I do that I will receive an exception immediately.
I'll try but I don't know if I can reproduce it in a minimal code.
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am

Re: Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby NateS » Mon Jan 03, 2011 12:10 pm

Can you try with the latest from SVN? I've been reworking the maps in the utils package. I just checked in my cuckoo masterpieces. :)
http://code.google.com/p/libgdx/source/ ... ava?r=1274
The cuckoo maps are very fast and efficient.
NateS
 
Posts: 1980
Joined: Fri Nov 12, 2010 11:08 am

Re: Rev.1256 - Rev.1267 Some null point exceptions in box2d

Postby gamefish » Mon Jan 03, 2011 1:23 pm

Nates wrote:Can you try with the latest from SVN? I've been reworking the maps in the utils package. I just checked in my cuckoo masterpieces. :)
http://code.google.com/p/libgdx/source/ ... ava?r=1274
The cuckoo maps are very fast and efficient.

Thanks for the maps, great job! But I can't test this problem for now.
I re-factored my whole project since last two days, due to too many objects creation that causes GC lags. Now in my code I don't delete bodies, just store them in a pool and de-active, re-active them for my needs (actually I pooled almost everything even the Vector2, thanks to the GC evil). The null pointers problems just gone, but I believe they'll return i delete bodies instantly(not in callback).
I'll try to write a small test to reproduce it as soon as I find time.
More fancy android games at http://www.html5game.com
gamefish
 
Posts: 18
Joined: Sat Dec 18, 2010 4:20 am


Return to Libgdx

Who is online

Users browsing this forum: No registered users and 1 guest