I am having a performance issue in my new game, and while I’ve tracked down the issue in the micro-profiler, I’m not sure how to go about dealing with it.
Essentially, once players open on the order of 1000-2000 eggs in my game, performance starts to tank and frame-skips start occuring. In the microprofiler, I can see the the PreRender task is taking something up to 100ms, this mainly being caused by TweenService taking a huge amount of time to resolve. This happens while opening the eggs, but what’s strange is that it also continues to happen every few frames after the egg opening animations are finished.
I know this is likely to be something specific in my own code that is causing it, but does anybody have any ideas what the issue might be? I am cleaning up all of my tweens, and destroying them/the objects they are attached to once they are completed. I also don’t have any infinitely looping tweens that could be causing this issue. A memory leak I also find unlikely, as that would cause increased memory usage (which I haven’t noticed an appreciable amount of), rather than every 3-4 frames a huge TweenService computation being performed.
None of my scripts are taking up more than 2% in the script performance window either, if that makes any difference.
Normal frame (haven’t opened any eggs):
After opening ~1000 eggs (frames still aren’t dropping but you can see a large load):
Post 2,000 eggs (a good frame):
Post 2,000 eggs (a bad frame)
You can see the for some reason TweenService is taking a huge amount of time to complete, despite (to the best of my knowledge) there being no active tweens. Does anybody have any ideas what might be causing this?