Unity 5.2 inconsistent performance (‘pulsing’) / especially with ReadPixels

So I upgraded my project from Unity 5.1.1p3 to 5.2, and I’ve noticed that the performance seems to be off. For the most part it runs nice and smooth, then it seems to enter a state where a smooth pan (in game or in editor) has a ‘pulsing’ quality – almost like it gets hung up every fixed update or such. To be clear, the framerate doesn’t drop, and it’s not even like it has a hitch / dropped frame… it’s more like briefly but smoothly slows down slightly every 0.25 seconds or so.

This is also quite inconsistent – sometimes this happens as soon as I start playing in editor, other times after some new objects have been added, and other times it goes away after playing for a while. The states last a fair amount of time – so it’s either pulsing and not running smoothly, or it snaps and the starts running perfect for minutes – then it starts pulsing again. When it decides to run smoothly, the performance is comparable to 5.1.1p3.

I also started a new VR project with Unity 5.2, and the pulsing is present there as well. The scene is extremely empty, and almost no script at this point, but the pulsing is still noticeable – and while subtle, it can be very uncomfortable in VR. In my other project, the pulsing seems relating to CPU load – so where we’re normally at ~ 4.3 ms (in 5.2 – more on that later), when things get busy it gets up to 7-8 ms, and the pulsing starts to feel really disruptive. What’s odd though is it’s not direct dropped frames – it’s almost like the physics slows down and the render thread updates normally. We’re using 2d physics.

To exasperate things further, my project uses ReadPixels to get some material back from a custom shader setup. The Texture2D is small, and the performance has been bearable – about 2-3 ms per fixed update in Unity 5.1.1p3. (at least this is what I see in the profiler – and even with the profiler open the game runs smoothly). In Unity 5.2, when I open the profiler the gfx.read event is now taking 140 + ms, and the entire game becomes an unresponsive mess. When I close the profiler, it goes back to normal – occasional pulsing states and all.

In Unity 5.1.1p3, my CPU time is ~ 2 ms per frame, and there is no pulsing. I can have a rather busy and complicated scene, and I will barely hit 4-5 ms. In Unity 5.2, my CPU time is starts at ~ 4.3, quickly rises to 6-7 ms as soon as I add anything more than the player, and often enters into the pulsing states described above. (the pulsing states do not reflect on a change in the reported frame time, though the intensity of the pulse does seem worse with higher CPU frame times).

To be clear, while it looks like the script with ReadPixels has slowed down substantially and is likely responsible for most of that CPU difference, we notice the pulsing on a scene with absolutely no ReadPixels calls.

I’ve disabled all the Realtime GI, and can’t think of any other system it might be. We do not have any GUI work at this time, though I do have some sprites in the scene.

I am working on an NVidia GTX 670m, i7, and 12 GB worth of RAM. My Colleague noticed a similar phenomena on his machine with the same empty VR scene.

Any input would be appreciated, as right now the performance is painful enough for me to fall back to 5.1.1p3 L

1 Like

Try 5.2patch1 fixes a lot of things, tbh they rushed 5.2 release with far to many bugs and caused a mess on the forums with issues.
I would suggest ppl upgrade to patch releases asap and retest…

Just upgraded to 5.2.1, but the editor pan/zoom lag still shows up after a few minutes of inactivity (somewhere around 15 or so), and persists until I cause a recompile.

Further investigation reveals that the CPU usage for unity jumps to 30% on my machine, but drops to 1-4% after triggering a recompile (until it happens again). I added a simple cron to change a file to trigger re-compile every 15 minutes as a work around.

I first noticed this 5.2.0, but it still exists in 5.2.1.

My stats:
Windows 7
AMD Fx 6300 6core
8GB DDR3
AMD R9 270x
Unity install on SSD

Hey, any chance you could capture a CPU Usage trace with Windows Performance Recorder when the performance degradation happens and send it to us?

I believe I am getting this issue too, ever since 5.2 onwards I’ve noticed that my movement in the game has a pulsing/stuttering all the time, like a very fast up and down speed, not smooth movement, this shows in Gear VR and in the editor (even though the frame rate is hundreds of fps in editor). Also the frame rate has dropped in my first level from 60fps+ on gear VR from around 40-60.

I have sent a bug with the project, bug 730847.

Hello Tautvydas Zilys, I have the trace saved. I was tracing when Unity.exe CPU usage went from ~10% to ~40%, and stayed at ~40% while the unity editor was minimized. Do you want the .etl file, the resulting folder, or both?

Just the ETL file. If you could submit a bug report with that as an attachment and give me the case number, it would be helpful in determining the cause.

Thanks for you assistance, Tautvydas. I’ve uploaded a bug report with my project and .etl file. I’m awaiting a confirmation email, which I assume will provide the case number. I’ll update when that arrives.

Edit: (Case 731009) Editor chews up 40% of CPU after update from 5.1 to 5.2