Speeding up BRIK Brick Breaker

Physics engine box2D is an excellent tool that makes writing games much faster since it provides all the physics and collision detection you might need. In case of BRIK Brick Breaker I had some performance problems with it – when a some objects got stuck between bricks the game was quickly slowing down to a crawl. Soon I was forced to act when on one level the physics took 180ms to execute… A thorough investigation allowed me to find the reason for such slow down – when objects are stuck and overlap with other objects they try to get free and the impulses during collision increase to infinity. As a temporary solution that solved it in one line of code I have decided to cut out all such impulses (with very high values) in postSolve – it worked. The game is now fast and fluid even on older hardware.
Permament and better solution would be setting dumpening for linear and angular movements for all objects to a non-zero value because I suspect the impulses wouldn’t rise so high then: