matter-js: v0.18.0 introduces major bugs with collisions with sleeping bodies spamming collisionEnd indefinitely

Upgraded from v0.17.1 to latest to hopefully see some performance upgrades. Verified performance is pretty much the same but there is a nasty bug introduced if you have Engine enableSleeping true. Bodies that collide with sleeping bodies will have Matter.Events.on collisionEnd spammed indefinitely until you restart the server. It’s pretty easy to reproduce.

This issue will likely happen more frequently than expected to anyone using Engine enableSleeping true as it’s quite difficult to manually manage sleeping bodies when you want and not have the lib auto sleep everything including static bodies, this is due to sleepThreshold=-1 being so difficult to set in a manner that sticks, but that is an unrelated older usability issue.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@liabru I have also been seeing this bug the past few days. In my instance I have a game where when a body collides with another particular static body, the first body will be set to sleeping then removed after a set amount of time. What I am noticing is that the collide end event will continue to fire even after the body is removed from the world. I set up a code pen to demonstrate:

https://codepen.io/tropicalpudding/pen/LYzgaXK

I wanted to report that I has similar issues with sleeping collisions when I switched to 0.18 I just tried the alpha build from here and the problem went away. So I can also confirm the fix, thanks!

(the issue for my game occurred when you use an ability that freezes time for everyone but the player called time dilation, https://landgreen.github.io/sidescroller/ )

After digging in it turns out a more complete fixed required a few more edge cases. I’ve updated the alpha build on #1079 if you want to try it.

@fishmongr thanks for providing the additional example it looks like the above update is working on it, take a look if you can and let me know.

I’ll likely look to improve static scaling later on but for now other improvements have priority unless I see that it’s affecting a lot of users (sorry not looking to consult on this at the moment though but appreciate the suggestion).