Hello,
So I’m a fairly new programmer and I’m doing a project which is going to be physics based (not fully, depending on performance). Now I have a fully working prototype but I’ve hit a wall that I cannot get past. Before I go nuts building levels I want to get basic optimization down. The issue is that, while in a level, the game lags randomly. Without input, without movement, just idling. I cannot see why in the profiler, all I see are things like WaitForPresentInGfx or Semaphore.WaitForSignal when the spikes happen. I’ve attached 2 screenshots right when a spike happens.
On top of that, here’s some additional info:
With dynamic batching, the usual # of batches/draw calls at any time is 40-65.
SetPass calls don’t exceed 25.
Max tris on screen = 19k
Most performance heavy aspect: Upon ball collision, I have a script that uses the sphere overlap method to grab nearby rigidbodies. Then it assigns a new tag “Hit”, removes all constraints (so that gravity and ball force work. The reason they are constraint is because it’s voxel based and many voxels need to float). Then the ball applies force to them to blow them away. Now, according to the profiler, while there is a small spike when the ball collides, it’s not noticeable and this issue happens when idle.
All voxels (for example in level 1, 396 objects) get instantiated upon scene loading. Any objects already hit get destroyed. Once a level is done, a new scene is loaded if player chooses to go to the next level. This is done to save space as I’m planning 500 levels+.
All objects use the mobile diffuse shader. Everything except the voxels (because they move around) is static and baked into lightmaps.
I have no clue what else to do about those random lag spikes. Any help is very much appreciated.
Side note: Performance is always worse when running a development build. When running a release build game performs up to 30% faster.
Devices tested on:
Samsung Note 8
LG K30 - Extremely crappy phone, however performance is consistent (20-30 FPS).
Additional question:
Could it be the phone itself? Granted the Note 8 is quite capable, but I do notice that the phone itself has those mini lag spikes randomly. My question is rather, if the phone itself is hiccuping, will the profiler pick it up as well? It would explain how a crappy, crappy phone has solid performance (well, yeah, it’s half the FPS, but it’s steady) and mine doesn’t. Currently waiting for an HTC used from 2014.

