5
\$\begingroup\$

I am making a 2D mobile game and it runs really well (60 fps) on my phone. However, in some cases the performance goes down drastically to the point where it runs at 20 fps or even less. It happens at random times so I can't pinpoint what is causing this. During the performance decrease Gfx.WaitForPresent appears in my profiler which eats a lot of power. I am aware that this might be because of Vsync being turned on, but I have it disabled, along with shadows, AA and everything else that absolutely kills mobile performance. What else can be the problem? My game relies heavily on good performance for gameplay so this needs to be resolved ASAP.

Edit: I also noticed that the GPU stays at 0 ms which is really odd as well.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Are you perhaps using Unity 5.2.*? \$\endgroup\$ – jgallant Jun 21 '16 at 11:04
  • \$\begingroup\$ @Jon Unity 5.3.5 \$\endgroup\$ – Milen Jun 21 '16 at 14:00
  • \$\begingroup\$ I've been seeing this lately on my Surface too, but not on my desktop. I'm suspecting it has something to do with my use of multiple cameras and a RenderTexture but I haven't tracked it down conclusively yet. \$\endgroup\$ – DMGregory Jun 22 '16 at 4:59
  • \$\begingroup\$ GPU is at 0, because not all GPUs are supported by the profiler, such as the phone you are using. docs.unity3d.com/Manual/ProfilerGPU.html \$\endgroup\$ – Evorlor Apr 10 at 19:28
1
\$\begingroup\$

Disabling "multithreaded rendering" from Player Settings > Other settings might work (As these guys have pointed out)

My own experience was some postprocess effect was horribly conflicting with the hardware I was developing on (though mine was PC). I found out the culprit by deactivating everything (gameobjects and components) in the scene one by one. (I had noted down other people's solutions here)

Hope this helps.

\$\endgroup\$
1
+100
\$\begingroup\$

well I can tell you from my experience that for me the SpeedTree's caused that. what the profiler is saying to you is "I have to wait for rendering to end before i call for the next frame update" therefor you get this bottle neck that chokes your application and that's why it uses 0 ms. there is a tutorial made by Unity regarding the Profiler and at the middle approx. he is talking about this issue and name a few things that might cause it.

Live Training June. 22, 2015: Profiler Overview for Beginners

by the way its weird that its unity 5.3.5 cause on my profiler that Gfx.WaitForPresent is inside the Camera.Render and I can try and analyze it in a way.

good luck identifying the source of that. hope my answer helps.

\$\endgroup\$
  • \$\begingroup\$ I don't have any trees in my game so SpeedTree is not the problem. I will check the tutorial out, thanks :) \$\endgroup\$ – Milen Jun 24 '16 at 15:05
  • \$\begingroup\$ well the trees was just an example for why such a thing may happen since speedtrees shaders are badly occluded they give rendering a hard time. \$\endgroup\$ – Daniel Netzer Jun 24 '16 at 18:32
1
\$\begingroup\$

In the profiler capture it looks like SetPass and Triangles increase rapidly. Multiple cameras and render textures indeed can cause that because the scene has to be rendered multiple times.

\$\endgroup\$
  • \$\begingroup\$ I have only 2 cameras. One for the main rendering and another one for a blur UI effect. However the blur camera is disabled when there is no UI that needs it (during gameplay) \$\endgroup\$ – Milen Jul 1 '16 at 2:39
0
\$\begingroup\$

For me, a simple Unity restart worked out, lol.

\$\endgroup\$
0
\$\begingroup\$

I finally figured out what was causing my Gfx.WaitForPresent spikes . . . for me it was the Inspector inside the Unity Editor that was causing it. If I closed the Inspector tab, or switch to say the Lighting tab so the Inspector is not visible, my Gfx.WaitForPresent issues go away.

I could also control the frequency and amount of lag of Gfx.WaitForPresent depending on what I had selected while the Inspector tab was visible. I think the Profiler is taking the complexity of whatever the Inspector is drawing into account and that's when Gfx.WaitForPresent spikes.

At least on my system that is, I would try it and see if it does anything on your machine.

My specs: Win 7 x64 Unity 5.5.0f3, profiling from the Editor window (not external profiling) also profiling with Maximize on Play = Off.

\$\endgroup\$
0
\$\begingroup\$

My problem was a high resolution texture I used for terrain (8192 x 8192). It wasn't an all time lag, more like occasional spikes of 40-60 ms. It didn't matter if I'm zoomed in on terrain, or completely zoomed out scrolling camera around, spikes were the same. After that, I split the terrain into 1024 x 1024 chunks and spikes went down to 5 - 10 ms max.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.