YoYoGames/GameMaker-HTML5

Changing entity depths to non integer values gradually degrades performance

jefvel opened this issue · 1 comments

My game was getting worse performance the longer it ran, even though there were less than 40 active instances. After some troubleshooting, I noticed it had to do with the depth of instances. I changed it based on their y coordinate, going from 0 to 100.

It appears that it'll create pools for every unique depth, but then not remove them once the instance depth is changed or the instance is destroyed.

https://github.com/YoYoGames/GameMaker-HTML5/blob/develop/scripts/yyRoom.js#L3707
The pool list here kept growing every frame, to a size over 8000, at which point the game had ground to a halt.

However, if I made sure the depth was set to a rounded number instead of floating point between 0 and 100, the pool length was kept in check.

I'm not sure whether or not this is working as intended, I'm suspecting not. Either the depth should be ensured to be a rounded value, or make sure that the pool is cleaned of empty values.

reproduce_lag.zip
Here's a small project that reproduces the issue. Run it in a non-HTML5 target, and it'll run smoothly forever. However, HTML5 will gradually slow down.

Then, if you comment out the depth assignment in the step function test_obj, it'll keep running without problems.