b2EdgeShape

I'll run the CPU Sampler tool and have a look where I'm spending most of my time. I usually get a slow down when I load the scene and then occasionally another 2 second freeze about 5 seconds into the level. One thing I have noticed in the testbed example is the hasvertex0 and hasvertex3 (caps on the end?). I'm not using this, will this make any difference?

One thing I know for sure is the more edges I use the less performance I get.
Anyone have any idea on my actual problem? Erin?

I am simply performing a check on the Body's GetContact list and seeing which contacts are set to isTouching, however as stated in my first post the problem is that when I move over the edges I am getting an occurance after steping that no bodies are in contact (this occurs when moving to the end of the edge).
Another observation I have made is that the further I get on in a level the more spikes I get in performance.

I seem to be spending a lot of time in the following functions when there is a spike

TestOverlap
InsertLeaf
AABBCombine
GrowableStack
Roswell: I'm not sure what your question or problem is. Did you study the EdgeTest.h demo yet?

three: You have the same problem that the Tiles.h example has. Try inserting the edges in a random order. The problem is that the dynamic tree is becoming imbalanced. See: http://code.google.com/p/box2d/issues/detail?id=151
I've updated my code to create the edges in a random order and it has cured all of those spikes I was getting. I'm still getting the 2 second freeze at the beginning of the level though (about 5 seconds into the game).
Are you creating many shapes all at once? Try profiling that spike.
The problem is that the freezing was not showing in the profiling tool. I THINK I have eradicated the freezing and it turns out it was nothing to do with box2d. The random placement for now seems to have cured the stuttering I was getting towards the end of the level. I'll be doing more testing and report back if there are any problems but for now it's ok.
Ok so I've been doing a lot of testing and I'm 100% sure it is a box2d problem. When I load 200 edges about 1/5 of a level then the problem seems to be gone.

It's weird though because it doesn't freeze every time. So I'll change something and think that it has worked and then the problem is back again. It's also weird that nothing is showing in any of the profiling tools. Nothing at all and yet the game is locked for 2-4 seconds.

Still it's not all bad, I've made a lot of optimisations in the process. Just lost a lot of time stuck on this problem.
You'll probably need to insert timers in your code. You can detect a long frame and dump out the timings for that frame.
I'm not sure how to do that. But...

So today I stripped back everything since I last updated the game and when there wasn't any problems. One of the first things I did was edit the rider again. From the picture below you can see how my body is constructed NOW.

To move my rider backwards and forwards I am doing the following:
The pieces shaded in green are set to fixed rotation.
Each frame I am rotating each piece manually according to how each piece should be positioned and the rotation of the bike.

Previously I had a foot piece which was attached to the bike but I got rid of that because I thought there was no need for it.

If I keep the foot piece in all is fine. If I take the foot piece out I get the freezing. It was the last thing I thought was causing it but I think it is.

Original thread: https://box2d.org/forum/viewtopic.php?t=5634