cancel
Showing results for 
Search instead for 
Did you mean: 

Overhead/Gfx.WaitForPresent

braun0
Honored Guest
I am looking for some clarification and direction regarding some performance issues. My game is generally smooth, but often suffers from a stutter. I just enabled the profiler and got it setup so I can profile directly from the Note 4 while the game is playing. I immediately recognized that both Gfx.WaitForPresent and Overhead are causing spikes and killing my FPS.

Settings & version:
Unity v. 4.6.2
Oculus Mobile SDK 0.4.3
Mac OSX Mavericks
Fixed Timestep/Max allowed time = 0.166666
Vsync disabled
Quality settings set to Fastest (no shadows, Anti-Aliasing disabled, texture quality Eighth, Pixel Light Count = 0)
Other Settings (I have static & dynamic batching enabled)
I use Ambient Light (not a game component light source)

I believe I have followed all the settings rules outlined in the SDK documentation.

NOTE: All profiler data below if from the phone hardware (not my desktop).

Issue/Question #1: Gfx.WaitfForPresent
In my current build, this item in the profiler uses anywhere from 40%-90% of the CPU usage, with many occurrences pushing the FPS well below 60 (all by itself)

This example is from a static scene
https://www.dropbox.com/s/l23wtkxhbcbzkii/GFXandRender.png?dl=0

For a scene that falls into all the guidelines for Tris, Verts, Draw Calls (and quality setting turned all the way down) why is Gfx.WaitfForPresent eating up so many resources? As I understand Gfx.WaitfForPresent, it occurs when the GPU isn't rendering the frame fast enough for the CPU (causing the CPU to wait). Is this correct? What am I overlooking here?

I also tested an "empty" scene and Gfx.WaitfForPresent was also very high. I was very surprised that an empty scene couldn't even keep a consistent FPS over 60.

Issue/Question #2: Overhead
About once every 15-30 seconds the Overhead in the profiler spikes up to around 90% and it causes a huge stutter in the game. As I understand, Overhead can be caused by errors/warnings that appear in the console. When I run the game in Unity, I get no warning/errors in the console. However, when I run the game on the phone, I get about 14 warnings. All of them pertain to some value in various OVR scripts that are assigned by never used. Could all these warnings cause this spike in Overhead?

https://www.dropbox.com/s/y8npt5ohv06318n/overhead.png?dl=0


As a side note, when I play the game in Unity, the game as viewed in the "game" screen moves in slow motion. Meaning the player/game objects move very slowly compared to how fast the game actually is (when played on the phone). Has anyone else encountered this issue? Could this be a symptom of a Unity/SDK integration error?

Any input/advice would be greatly appreciated.
22 REPLIES 22

cybereality
Grand Champion
In general, Gfx.WaitForPresent and Overhead spike when the CPU is waiting for the GPU to finish rendering work.

Are other apps running? Does restarting the phone help? Do the SDKExamples we provide work?

It might help to look at the GPU profile on PC for clues.
AMD Ryzen 7 1800X | MSI X370 Titanium | G.Skill 16GB DDR4 3200 | EVGA SuperNOVA 1000 | Corsair Hydro H110i Gigabyte RX Vega 64 x2 | Samsung 960 Evo M.2 500GB | Seagate FireCuda SSHD 2TB | Phanteks ENTHOO EVOLV

braun0
Honored Guest
"cybereality" wrote:
In general, Gfx.WaitForPresent and Overhead spike when the CPU is waiting for the GPU to finish rendering work.

Are other apps running? Does restarting the phone help? Do the SDKExamples we provide work?

It might help to look at the GPU profile on PC for clues.



Cyber, I just ran a test using two of the SKD examples. For the most part, FPS fluctuates between 55-65 in the profiler. However, there is still a large spike once every 15-30 seconds. See the screenshots below.

SDK Scene "boot":
https://www.dropbox.com/s/bwtfba50536cabu/bootexample.png?dl=0

SDK scene "FirstPerson_Sample":
https://www.dropbox.com/s/c15ne5w224sra7a/FirstPersontest.png?dl=0

Is 55-65 FPS normal for performance on these examples? Is it acceptable to have the scene drop below 60fps for any amount of time (no matter how short)? Could those large spikes in Overhead/Gfx.WaitForPresent be specific to my device? I am running stock, not rooted, and with no open programs (besides all the junk Samsung pre-installs, as I have tried to leave this phone as stock as possible for testing/development purposes).

Thanks for your input/advice.

marchansenj
Honored Guest
Cyber, I am experiencing the same issue.

I went from getting 500+ fps to getting 40-60 fps in the unity editor. I also am seeing a spike every 10 seconds or so as braun0 described.

When I deploy to the phone and profile over adb I see the same results only a bit worse.

I have tried all of the SDK Examples and I am seeing Gfx.WaitForPresent at 96% with a frame rate of 40-65 with the spike every 10-15 seconds that brings it to 15fps.

I had no noticeable FPS drop and never noticed the Gfx.WaitForPresent when profiling before I updated the runtime and SDK to Mobile 5.0 today; maybe its just a coincidence.

The offending script is OVRManager.cs (which use to be OVRDevice)- If I disable that Script the Gfx.WaitForPresent goes away and the frame rate goes back to where it use to be 1000+. I see that the script when android targets 60 fps which is fine if Gfx.WaitForPresent wasn't gobbling up 90% of the resources and there wasn't the spike.

I have wasted an entire day on this issue.

Please if someone else has updated their SDK to the latest and is getting a high frame-rate and not seeing Gfx.WaitForPresent let me know so I don't chase a red herring.

Can our JAM entry be built using the previous SDK and runtime? Or are you guys aware of an Issue? Maybe I am missing a setting?

Thanks,
Marc

HappySlice
Honored Guest
I am experiencing the same problem on my Windows 7 machine. I was getting almost constant 60fps on my Note4. Then I upgraded to Unity 5.0.1 from 5.0.0f4 and also updated to the new Oculus runtime. I am still using the 0.4.3 SDK with all the default/suggested project settings.

My GPU on my Windows machine is old but I see spikes from 60 to 30fps on the graph from rendering opaque meshes every so often making, even in a scene I made with only ~12k total triangles.

Is there a way to profile the GPU directly from the Note4? I'm backing up my project now to update to the new mobile SDK. Hopefully more stuff doesn't "break" 😞

HappySlice
Honored Guest
Updated to Mobile 0.5.0 SDK and the performance is now almost constant 60fps again. My desktop version seems to run better too -- maybe it's just because the optimization I did for mobile though.

I just had to delete some duplicate plugins for it to compile due to being unable to convert classes into dex format

Mobile SDK 0.5.0
5.0.1 Oculus Runtime
Unity 5.0.1
T-mobile Note 4 on Kit-kat
Windows 7

HappySlice
Honored Guest
I still get Gfx.WaitForPresent spikes on my Win7 machine. They coincide with GPU spikes that I don't understand. Even when my character stands still... Does anyone know how to reduce these GPU spikes? The level is low poly, with about 50 draw calls even though everything is a cube (different scales though). Is it all about draw calls? Do I need less draw calls?

I'll have to wait until later to get time to post profiler screencaps from my Note4. Here are pics from the Unity5 Editor Profiler
http://imgur.com/foLTaTo,B74cm9d,IbESlR0,CsVjDCA
http://imgur.com/foLTaTo,B74cm9d,IbESlR0,CsVjDCA#1
http://imgur.com/foLTaTo,B74cm9d,IbESlR0,CsVjDCA#2
http://imgur.com/foLTaTo,B74cm9d,IbESlR0,CsVjDCA#3

marchansenj
Honored Guest
I uninstalled and reinstalled the 5.0 runtime and 0.5.0 SDK following the documentation.
I loaded the Cubes sample scene.
On the editor I see 55-75 FPS and the Gfx.WaitForPresent at 95%:
http://imgur.com/JNtdDAK

On the Note 4 profiling over Wifi I now do not see Gfx.WaitForPresent but still do see spikes every few seconds that brings the phone down to 30fps and every 15 seconds or so brings the FPS down the 15.

Overhead 83% spike down to 15fps:
http://imgur.com/HNS9dvD
Callback Coroutine 55% spikes to 30 fps:
http://imgur.com/o2XBKm0

Should I be upgrading to Unity 5 I wasn't planning on it but I am at a loss?
Is there a player setting or something that would account for this strange behavior?
I am going to guess that not everyone is seeing this problem or we would see more posts like this.

Using Unity 4.6.3
Note 4 T-mobile/kitkat

braun0
Honored Guest
Thanks to everyone else for added to this thread. It appears that at least a few of us are having this issue with Overhead/Gfx.WaitForPresent spikes that are killing FPS. Since my first post, I have updated to Unity 4.6.3 and Mobile SDK 0.5.0 - and I still have the same spikes.

I have spent days attempting different settings/scenes and the spikes always occur (no matter how simple the scene is). I am hoping to at least get a response from Oculus regarding the spikes in the OVR demo scenes. Do they see anything similar when they run the demo scenes? Can they provide an example of what the FPS/profiler should look like in a particular scene?



Also, since updating to SDK v0.5 this appears in the Console each time I run the game in Unity:
OVRMoonlightLoader: Apply settings required for Android Mobile VR
UnityEngine.Debug:Log(Object)
OVRMoonlightLoader:.cctor() (at Assets/OVR/Moonlight/Editor/OVRMoonlightLoader.cs:51)
UnityEditor.EditorAssemblies:SetLoadedEditorAssemblies(Assembly[])

Is this script checking these settings and telling me they are NOT applied correctly? Is this script "applying" the settings for me? I am a bit confused by the use of "apply" vs. "applying". I have the settings below set properly in the Quality Settings section - so I am not sure what this notification is trying to tell me.

PlayerSettings.defaultInterfaceOrientation = UIOrientation.LandscapeLeft;
QualitySettings.antiAliasing = 1;
QualitySettings.vSyncCount = 0;

Any thoughts?

marchansenj
Honored Guest
I figured something out. But I have only tested with the Sample scenes.

The problem seemed to be trusting the UNITY PROFILER.
When I hooked up the Oculus Remote Monitor I am seeing a consistent 59-60 fps with only one spike to 54 fps over a 5 minute period of running the Cubes Scene, much much better then what the Unity Profiler was telling me.

Frame rate in the editor still sucks in 0.5.0 SDK with Unity 4.6.3 but that can be overcome by using an alternative camera for play testing when in the editor.

Let me know if you guys figure out anything else.

Thanks,