Stuck at world.step

Posts that don't fit into other categories.
soylomass
Posts: 22
Joined: Fri Nov 18, 2016 3:40 pm

Stuck at world.step

Postby soylomass » Mon Dec 25, 2017 7:29 pm

Hi again.

One year ago I made a post (viewtopic.php?f=3&t=312) about the engine getting randomly stuck at world.step, because of that problem I had to switch to libgdx-box2d.

Now, I'm making a new game, and I decided to use dyn4j because I really like it, among other advantages, but the problem happened again.

This new game was made from scratch. This time I've decided to find a solution as I don't want to switch engines.

In the old post, I found out that the engine was getting stuck at:


// after all has been updated find new contacts
// this is done so that the user has the latest contacts
// and the broadphase has the latest AABBs, etc.
this.detect();


This time it gets stuck at the same method, so I added prints inside it to see where exactly it happens, and when it finally crashed again, this was the result (got stuck on the red line):

// get their transforms
Transform transform1 = body1.getTransform();
Transform transform2 = body2.getTransform();

Convex convex2 = fixture2.getShape();
Convex convex1 = fixture1.getShape();

Penetration penetration = new Penetration();
// test the two convex shapes
System.out.print("a");
if (this.narrowphaseDetector.detect(convex1, transform1, convex2, transform2, penetration)) {
// check for zero penetration
System.out.print("b");




I'll continue trying to find the cause. Meanwhile, if anyone can help me, I'd be greatly pleased.

Thanks in advance.

PS: All the code is on World.java (org.dyn4j.dynamics.World)

PS2: I'm using all the default world settings except for gravity. Maybe I should try using another implementation of Narrowphase, given that it gets stuck at narrowphase.detect

UPDATE: I'll try using SAT instead of the default GJK, and if the problem happens again, I'll start checking where on narrowphase.detect it gets stuck.

zoom
Posts: 145
Joined: Sun Mar 17, 2013 3:57 pm
Location: Stockholm, Sweden
Contact:

Re: Stuck at world.step

Postby zoom » Tue Dec 26, 2017 5:17 am

If I recall correctly no one managed to replicate your results? I think this indicates something in your setup, either some world settings, which isn't likely, or more likely you have some fixture/convex that is special somehow. Just tossing ideas here but maybe some degenerate convex, like 0 area or some floating point value that is NaN.
Is there some test case you could share or sample code that shows the problem? The best way to get this fixed is to make it so others can replicate the problem. My humble suggestion is that you focus your effort into making a test case rather than debugging on your own.

soylomass
Posts: 22
Joined: Fri Nov 18, 2016 3:40 pm

Re: Stuck at world.step

Postby soylomass » Tue Dec 26, 2017 10:30 am

zoom wrote:If I recall correctly no one managed to replicate your results? I think this indicates something in your setup, either some world settings, which isn't likely, or more likely you have some fixture/convex that is special somehow. Just tossing ideas here but maybe some degenerate convex, like 0 area or some floating point value that is NaN.
Is there some test case you could share or sample code that shows the problem? The best way to get this fixed is to make it so others can replicate the problem. My humble suggestion is that you focus your effort into making a test case rather than debugging on your own.


This time the bodies are all boxes and circles, and some of the boxes (platforms) are weldjointed one at the side of the other, forming a bigger platform (1x2, 2x2, etc). The only thing that might not be right is that the welded platforms are not overlapping, and the weld point is only on one of the boxes, but I don't think that could be the problem, right?

I'd like to make a test case, but even if I did it, the problem doesn't happen always, and actually it happens while no bodies or joints are being created, only maybe forces being applied.

The other time I decided to switch to box2d because the problem happened only when people were playing it, and I couldn't make it happen when hosting the server on my PC. This time it happens on my PC so I can try to find the cause without disturbing players.

William
Site Admin
Posts: 377
Joined: Sat Feb 06, 2010 10:23 pm

Re: Stuck at world.step

Postby William » Tue Dec 26, 2017 10:57 am

soylomass wrote:This time the bodies are all boxes and circles, and some of the boxes (platforms) are weldjointed one at the side of the other, forming a bigger platform (1x2, 2x2, etc). The only thing that might not be right is that the welded platforms are not overlapping, and the weld point is only on one of the boxes, but I don't think that could be the problem, right?

I wouldn't expect that to be an issue.

soylomass wrote:I'd like to make a test case, but even if I did it, the problem doesn't happen always, and actually it happens while no bodies or joints are being created, only maybe forces being applied.

But there are still bodies in the world right? The detect method does nothing with forces, it only checks for collisions between two shapes, so for it to halt there, there must be some shapes in the world.

What would be useful is if you could print out the convex shapes and their transforms at the time the application hangs (toString should give sufficient information). This could allow us to produce a minimal test case. Some other questions:

  1. Does it always hang at that line (the line after you print "a")?
  2. When you used Sat as the narrowphase collision detector, did that prevent the hanging?
  3. Can you turn off Continuous Detection and test again (Settings.setContinuousDetectionMode(ContinuousDetectionMode.NONE));

Thanks,
William

soylomass
Posts: 22
Joined: Fri Nov 18, 2016 3:40 pm

Re: Stuck at world.step

Postby soylomass » Tue Dec 26, 2017 12:15 pm

Will try to do what you asked and answer your questions as soon as it gets stuck again (if it does, because I changed to SAT, and even if it does it may take a time, as it's totally random).

By the way, is there a performance lose by using SAT instead of GJK?

About the first question, last time was the firs time I debugged inside this.detect();

But I can affirm that every time it gets stuck at this.detect();

William
Site Admin
Posts: 377
Joined: Sat Feb 06, 2010 10:23 pm

Re: Stuck at world.step

Postby William » Tue Dec 26, 2017 8:55 pm

soylomass wrote:Will try to do what you asked and answer your questions as soon as it gets stuck again (if it does, because I changed to SAT, and even if it does it may take a time, as it's totally random).

soylomass wrote:About the first question, last time was the firs time I debugged inside this.detect();

But I can affirm that every time it gets stuck at this.detect();

Thanks, that will help us track down the problem.

soylomass wrote:By the way, is there a performance lose by using SAT instead of GJK?

SAT is probably faster, but it doesn't work with some shapes (Ellipse and HalfEllipse only work with GJK).

William

soylomass
Posts: 22
Joined: Fri Nov 18, 2016 3:40 pm

Re: Stuck at world.step

Postby soylomass » Tue Jan 02, 2018 9:50 pm

I want to report that until now it hasn't got stuck once while using SAT. Will keep testing given its randomness, but more time has passed than between previous stuck events.

William
Site Admin
Posts: 377
Joined: Sat Feb 06, 2010 10:23 pm

Re: Stuck at world.step

Postby William » Mon Jan 08, 2018 10:22 pm

soylomass wrote:I want to report that until now it hasn't got stuck once while using SAT.

That is good news.

soylomass wrote:Will keep testing given its randomness,

Please do, I'm very interested in fixing this issue.

William

soylomass
Posts: 22
Joined: Fri Nov 18, 2016 3:40 pm

Re: Stuck at world.step

Postby soylomass » Tue Jan 23, 2018 3:29 pm

I can confirm after all this testing that it doesn't happen with SAT.

I'm finishing the first release version, I can help with trying to find the GJK bug cause after I publish it and have more free time.

William
Site Admin
Posts: 377
Joined: Sat Feb 06, 2010 10:23 pm

Re: Stuck at world.step

Postby William » Wed Jan 24, 2018 10:01 pm

soylomass wrote:I can confirm after all this testing that it doesn't happen with SAT.

That's good news.

soylomass wrote: I can help with trying to find the GJK bug cause after I publish it and have more free time.

Please, if you do have time, that would be much appreciated.

William


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests