I am trying to fix a lag spike that occurs in frequent intervals in my game but I can’t find the cause of it. This spike is visible on the Micro Profiler and shows this:
The profiler states that there is “Simulation” which involves “physicsStepped” this frame.
I can’t find any scripts that could be causing this and I don’t know how to interpret the information on the image.
The game is a baseplate with some small builds on it, an ACS gun system and some A-Chassis vehicles. The game also has Streaming Enabled on so it might be due to this?
Any help is appreciated in finding and fixing the cause of this lag spike.
Your microprofiler screenshot is of the internal physics engine’s work. A little odd that it’s performing 8 steps in a single frame, though. Do you notice any correlation between in-world actions and these lag spikes?
My best-guess is that this is the result of complex assemblies colliding with something. It may be worth looking into how to reduce the complexity of your collision geometry if you haven’t already, since it looks like some of your assets are fairly high-fidelity, so their default collision geometry will be fairly high-fidelity, as well.
I can’t find any connections between in-game actions and the lag spikes. However, they only start showing up after around 3 minutes from joining the game, then occur every few seconds.
Regarding the assets, this lag spike has been showing for a while and before most of the higher-quality assets were added to the baseplate so I don’t know if they are the cause of the lag spikes.
Are there any possible causes of this type of performance issue?
I can’t really think of what would cause the physics engine to act up in that way other than it trying to solve a calculation it doesn’t like. My only further recommendation would be to remove physics objects one-by-one and see when/if the frame drops stop. If you can find the offending asset, then maybe you can figure out what about it the physics engine disagrees with.
Is the microprofiler screenshot from a live server or from Studio? If I take like 8 copies of the old ROBLOX HQ model, unanchor them, and let them collapse, I am able to get more than 4 “WorldStep” actions in the microprofiler, but my assumption is that that has more to do with my computer running both the client and server physics simulations without enough processing power to keep up.
If I publish the place filled with models, join it, then unanchor everything, I get different results depending on network ownership. If I do not change the network ownership, all I get is an incredibly slow building collapse as the server does all the work and sends it to me, but I do not experience any performance hits. If I assign myself as the network owner at the time of unachoring everything, my computer does indeed melt under the strain of the physics simulation, but, rather than seeing more “WorldStep” actions per frame, I see fewer as the engine gives up and moves onto the next frame.