FPS periodically drops to 20

Would this be a hardware issue, or have something to do with the project itself? I added in an fps counter from this tutorial, and every 15 seconds or so this issue occurs. It’s not just that the counter is outputting the drop, if something is updating at the time of the drop there is a noticeable pause.
Here’s the project.

20 fps is quite smooth.

Looking at the performance profile in Chrome devtools, it’s due to the (major) garbage collection triggering. Is there anywhere in the project where you are creating new objects every frame? (e.g pc.Vec)?

This also might be in the p2.js library or integration code.

When it’s an instant drop from 60 it’s quite noticeable.

I don’t see any, here’s a link to the script if you have time to look it over and find anything I may have missed: Manager.js

Okay, now I’m less sure after profiling it again. In some cases the layer seems to be taking up most of the frame but not exceeding 16ms so I’m not 100% sure what it could be.

This frame skipping has happened in other projects related to this one, I just thought that in those ones it was occurring randomly. Maybe I should add the fps counter to them and time it like I did with this one.

Barely. I’m used to playing at 10 fps so. :stuck_out_tongue:

Are you using touch input? Because I had noticed in the past the PlayCanvas touch implementation seems to trigger garbage collection quite frequently. It creates a ton of objects.

[edit] I notice, looking at the project that you are using mouse input - I noticed on an older machine my frame rate dropping a lot - it looked like garbage collection related to events when I profiled it. Does the issue occur when you are not using input? (i.e. just letting it run)

Yeah, it happens no matter what I do. If I click launch and just leave it, it happens. If I click the button it happens while the wheel is spinning and after when nothing is going on.

Sound like you need a serious upgrade, unless it’s intentional.

Why are you using both P2.js and Ammo? I notice that there is a massive frame rate drop early on - every time, related to Ammo trying to update the world…

So it appears you are using a spring simulation for the wheel… but the arrow thing is handled by P2.js? That seems to be a recipe for disaster.

I’m beginning to realize that’s going to be a problem. I just recently set that up and the issue was occurring before.

Yeah. I have an upgrade now that I get at least 15 fps with (usually 20-30) but still need better. No money is the problem.

I feel you there :grin:

1 Like