When starting to profile our project using both the built in profiler and our own code, I noticed two possibly related problems, one very severe. In order of importance:
With a new project and empty scene, a standalone build of Unity will run for a minute or two at very high FPS (vsync disabled and target fps = -1), then it will suddenly drop to 60fps as if vsync had been enabled or a target framerate set. Remember, new project, empty scene. Gfx.WaitForPresent takes up the vast majority of the frame time. Activity Monitor will show the energy usage for the player dropping at this time.
Why does this happen? It must be a Unity bug, and/or an operating system issue.
When running in the editor, RenderTexture.SetActive will fill up GPU usage to hit 60fps (which is what I believe the editor is capped to?). Minor problem, but I would rather have this labeled correctly as I cannot see how a rendertexture could be involved as the scene is empty. Or is the same procedure used for the Editor GUI?
Anyway, I rank #1 as extremely severe considering developers may want to target framerates above 60fps. Developing for the Rift DK2/CV for example will require a higher target. At this point it seems impossible to hit anything more than 60fps consistently since something is throttling performance.
(This is on a new Mac Pro with dual D700s and the operating system is not set to enable App Nap or anything else that might interfere with performance).
Will probably log a bug report, but would like feedback here as well. Thanks!
This is how it looks in the profiler, regardless if running standalone, in the editor, with/or without the profiler attached (a simple fps-script will confirm this happening as a non-dev build with no profiler attachment). First it will run for 1-3 minutes at a high framerate, then suddenly the FPS will drop while gfx.Waitforpresent takes up the time. Again, empty scene, new project, vsync disabled and target framerate = -1.
Are you in Editor or connecting the profiler to a built player? The in Editor profiling has to do some ‘magic’ to pretend that the Editor is not there, but it can’t be trusted 100%.
I did both, and while the label of the “offending” task varied (RenderTexture.SetActive in the editor, gfx.waitforpresent when profiling built standalone), the metrics were very close. 800-1000fps for a few minutes (1-3) and then 60fps for a while and so on. It appears vsync was being switched on and off.
Now, my efforts to reproduce this since the first report have been only intermittently successful. I cannot rule out that there is something external going on here, in fact it may be likely that some other App is interfering.
However, what concerns me is not that the performance degrades as other apps demand GPU resources, but rather that it over the course of a couple of frames drops from 800-1000 to a seemingly vsynced 60fps.
Regardless of the cause (Unity bug or Apple OpenGL driver problem) it is a real problem for all Unity Developers. A customer will not care what causes these performance drops, they will kick and scream in our forums and write bad reviews. Therefor I would very much appreciate if the dev team took this report seriously.
Have you forced vsynv off via script? That did not help us back then (the thread is 1.5 years old), but I am happy to report that after 5.x this is no longer an issue for us, and that is in a very complex project.