I have a side-scrolling platformer type game with procedurally generated terrain, see below. The pink circle is a dynamic body for the player, the green area is a single static body and each of the tiles is a fixture.
The player can move left and right and jump, via linear impulses. Now, most of the time this works fine, but every so often when I'm jumping around the player body suddenly falls partially through the ground body and gets stuck:
I can't discern any pattern to this, it just seems to happen at random. The degree to which the player falls through also varies quite a bit, sometimes you just clip a little bit into the terrain and other times you fall through 15 or 20 tiles.
I've found threads on here with similar problems of bodies ignoring collisions, one suggestion was to increase the velocityIterations and positionIterations arguments of the World.step() method. I've been trying that and it doesn't seem to matter. Another suggestion was to set the player body as a bullet. Again, tried it and it did nothing. So, any other ideas?


You should be doing something to coalesce your boxes so that you can cover the filled areas with a fewer number of objects. As is, it’s very inefficient and each gap is an opportunity for something to go wrong and allow for getting stuck inside as you report.
You definitely should look into computing the boundary and forming chain shapes on that boundary. This approach also means you won’t need to coalesce the boxes. You’ll want to still find a way to handle getting to the wrong side of the chain shapes but that’s still a cleaner approach, and besides, TOI calculations on chains will work way better than tons of separate little boxes.
Consider this, when you have a fast moving object slamming into a group of static boxes, even if the object is marked as bullet the system will try to ensure for each box that the object is about to penetrate that it will not penetrate them individually, and sequentially compute that, but this may still leave the dynamic object penetrating them in the end because they are all separate boxes! A chain shape is one single shape and will not have this problem, but you should still have some backup plan for if the dynamic object does somehow make its way to the wrong location.
Because of these nuances it is potentially useful to both have your static geometry wrapped in chain and space-filled with fixtures, and you can detect “stuck” states by looking for very obvious patterns in events (if on every single dt you get huge impulses from multiple static objects onto one dynamic object) and handle it accordingly.