A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Separate names with a comma.
Discussion in 'Editor & General Support' started by jordi_boni, Nov 15, 2013.
What's the meaning of gfx.WaitForPresent? How can I resolve this performance matter?
I was experiencing this too actually, and to be quite honest. I found that having the profiler open every play test was causing me performance issues inside the unity player. Probably due to the constant draw calls to that GUI window. I close it and everything is smooth again. And I just ran a test, I am experiencing a lot of gfx.waitforpresent too. I *think* it maybe a vsync thing. But I could be wrong. Do you experience poor performance with profiler closed?
I am profiling from my computer to another computer running my application connected to a TV
Ah, well even still. I never liked the performance of a tool that's supposed to help performance
I'm having a similar issue. In my case, it takes up to 50 ms.
Similar issue in my case. VSync seems to be causing it because my game is extremely smooth without it on but when it is I get the same WaitForPresent spikes. The strange thing with my game is that after adding a LOT more objects to the scene it runs extremely smooth again.
Same here, what is it? VSync is disabled.
I think it has to do with swapping around the active RenderTexture. Normally the lag induced by having the profiler open would show up as RenderTexture.setActive, but I think they tried to detect this and instead display it as Gfx.WaitForPresent.
Though, the RenderTexture.setActive still seems to show up for DigitalAperture (the purple section).
Same problem here. So is it only linked to the fact the Profiler is open and running then?
Bumping this for more attention, My application also suffers from this
I think we need to open a bug report and than vote it here: http://issuetracker.unity3d.com/
This is 4.3 related. Anyone? I'm curently out of office.
Same here. Uses 20-65 ms on the CPU when profiling connected to my OUYA.
Gfx- waitforpresent use to be called device.present.
According to the old forum post (http://forum.unity3d.com/threads/86312-Device-Present-in-profiler-what-the-deal) two reasons it would show up:
"you are too fast - refresh rate is 60hz and you are ready after 10ms - 6ms you need to just wait
you are slightly too slow - same as before - but you are ready after 20 ms - you will wait 13 ms (up to 33ms = 30 fps)"
Same issue here. This was not present in 4.2.x
waitforpresent, that should be the device.present as suggested, is actually a good thing...it means you are GPU bound and the CPU at a given point (usually 3 fames ahead) must wait for the GPU to finish. (IT also could mean that you need to optimize your rendering )
ah btw, today I noticed that profiling inside the editor gives completely wrong results! Try to build your application and profile your application externally instead!
Ok, i opened a bug report (Case 579069).
I was playing with a simple empty project and some balls bouncing around with diffuse shaders and no fancy post effects -> 1900/2000 fps. Then i started to add a secondary camera, a rendertexture, and some post effects. Unity started to drop fps to 120/130, and showing in the profiler a 99% cpu usage by Gfx.WaitForPresent. I removed everything: cameras, post effects, rendertargets, etc. I have ONE ball bouncing. Still at 130 fps with WaitForPresent at 99%.
I think there is something broken about rendertargets in 4.3 ...
We are not alone XD
I'm having a similar problems, and it is very frustrating. Does Unity not have a list of profiler stat names to find out what this is? It's hard to fix an issue if I don't know where to look
Same problem, Just appeared since 4.3. Wish I could share more light on the situation but I got nothing
Another one here for Gfx.WaitForPresent. I agree that there should be definitely be a breakdown in the Unity docs about the profiler stat names.
FWIW on android I get this with multithreaded rendering enabled.
With multithreaded rendering disabled I get some more reasonable looking profiler output.
So is this an expected behavior of the profiler or is this a 4.3 bug? And if it is, did anyone open a bug report yet?
Got the same issue. The most interesting - we fixed this in 4.2 by disabling VSync in Project settings. But then we got this trouble back after update to Win 8.1 and Unity 4.3. And even VSync disabling doesn't help. So now I cannot understand, is it Win 8.1 issue (cause all projects, compiled in 4.2 and worked in Win 8, are crashing down), or this is a Unity 4.3?
So,... it dissapeared from the profiler when i turned the shadow quality down to medium from high... strange
@Djekaster: Well I'm on Windows 8 so I would say 8.1 is not the culprit here...
@CaptainKirby: I assume you mean the shadow texture size in the project's Rendering preferences. I tried that but it didn't fix the issue.
One precision: I use DX11.
Mine was working fine the other day while I was optimizing a script, just had an empty scene with my script running on a game empty with Vsync disabled, FPS in the 1000's, then for no apparent reason, with no changes made at all, I started getting 250 fps, and GFX.WaitForPresent taking up 96% and causing red spikes all over the place...no explanation for this......sometimes it happens, sometimes it doesn't, sometimes when I hit play it starts of at 250 fps with Wait for Present and then randomly stops and Im back at 2500+ again.
Completely lost as to why this is happening......I always took it as a vsync thing which is fine, but it shouldn't be doing it if I have vsync off.
***Edit - It's working fine again now....after a few play's...I really dont get it...
Got a same problem. I use 4.3.1f1 version of Unity3D.
I want to make a tile background with parallax. So I render via SpriteRenderer Texture2D with WrapMode : repeat, like that:
var texture = (Texture2D)Resources.Load("background");
var material = (Material)Resources.Load("tiling");
SpriteRenderer renderer = gameObject.GetComponent<SpriteRenderer>();
Sprite sprite = new Sprite();
sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0, 0), 1.0f);
renderer.material = material;
renderer.sprite = sprite;
In material "tiling" I'm use default sprite shader modified in this way:
OUT.texcoord.x += _TextureOffset;
I did it for scrolling texture, couz standart SetTextureOffset seems not work properly.
So, in Update method I added a script for shift a texture, let's simplify it for understanding to:
renderer.material.SetFloat("_TextureOffset", i * Time.deltaTime);
Okay, it work well! But, on the surface it look a bit jerky. Profiler says me what it happen when Gfx.WaitForPresent got a spyke. Ok, maybe I assumed what I overloaded GPU, but indeed I don't. It's easy to check - just create an empty project. Unfortunately, the spykes still here
I try to disable VSync but it seems have no effect.
Please, help me! I'm going to get upset(
i confirm this is happens to me every time i play in editor... not sure if it occurs on the other devices
it does not depend on device. I checked.
Did anyone post a bug report about it? If so, is it already on the issue tracker page?
I submitted a bugreport but they told me it's not reproducible. We need to create a simple project that reproduce this bug and send to them
This problem exists mostly for users who have eithor updated their Windows device to the lastest 8, or are using 8.1. I have done a few tests myself and have noticed this only occured when I eithor updated windows, or ran it on my 8.1 machine (my main one). Not sure how the devs state it's not reproducible since for me if I open the editor (pro and indie) on my 8.1 machine with an empty scene, disable V-Sync, you will see the profiler display gfx.waitforpresent (pro) or half of your usual fps mileage (indie). I'm going to take a guess and say it may be in relation with an NVidia override of Unity's settings but I have no idea. Bumping for attention. Lets hope for an update.
This IS a bug.
If you read ALL the previous posts in this thread you'll find that this bug happens also with no vsync option enabled.
It could be related to gpu bound situations, like when you're using render targets / render textures. But that BUG, in my case, came out when i updated to Windows 8.1 and Unity 4.3.
Probably it's a bug. Look at this in my scene
Got the same thing here with 8.1. Completely eats the CPU speed continuously and is causing my game to run like a snail.
Could any of you send a bug report with an attached sample?
So I was experimenting in my project which previously had the gfx.waitforpresent, when something most peculiar happened. In the profiler under the GPU profiler, it failed to detect my graphics card (yes it's functioning fine just unity couldn't detect it at the time). When this occurs and it can't "monitor" the gpu, there is NOT ONE CALL to Gfx.waitforpresent. I'm going to see if I can find a way to invoke this detection error as there seems to be a 100% correleation with the profilers Gpu profiler and GFX.Waitforpresent. Hope this helps anybody. Also yes I am using 4.3 and Windows 8.1.
Hey guys so I recently have found a fix for this through experimenting but it comes at a cost. If you are using Unity pro's realtime shadow's they may not work for you should you choose to do this but it's not permanent. The reason you guys are getting this is due to Direct X with 8.1. The only way I have found to eliminate this gfx.waitforpresent is to go to your Unity Shortcut, under target where it says "C:\Program Files (x86)\Unity\Editor\Unity.exe" (or w.e your path is) append this "-force-opengl". Only Windows uses opengl so if you are getting this on a linux or mac sorry. If you've never added targets before here's an example of how your target should look like quotes included: "C:\Program Files (x86)\Unity\Editor\Unity.exe" -force-opengl
Sorry, in a rush but fyi you can still use Unity's shadow if you change your lighting method to forward rendering (blonde moment lol). So there's no cons involved so long as you aren't using DirectX only features. Let me know if it worked for you
I would like to confirm that this is indeed a bug. I have been getting alternating FPS and thread caps after quitting unity and reloading the scene. Gfx.WaitForPresent is the culprit
I am using 4.3.1f and windows 7 (dx11) - so this confirms that the bug affects win7 users also.
Cryztalfox's fix has indeed brought my thread back down below 1 and FPS is capping at around 1k - thanks for helping out dude.
I'm still wondering though, will this issue affect builds - forcing builds to also target -force-opengl ?
Just tried Cryztalfox's work-around and it seems to stop the Gfx.WaitforPresent showing, just unfortunate that a couple of my shaders requires DirectX, so will hopefully see some kind of fix soon, or at least an acknowledgement that there is an issue here.
I am having the same issue but I'm using a lot of post effects. I found that changing my shadow resolution from Very High resolution to High resolution seemed to have reduced the WaitForPresent time somewhat.
I also found that I had a very high resolution texture for my Skybox (4096px), and reducing that down to a smaller resolution also seemed to make stuttering go away.
Ditto also having this problem.
It has slowed my compiled build down significantly, juggling anywhere between 60 and 15 fps.
Hey guys, exact same problem here,
Edit - Modifying my findings:
From what I've found looking at this, it has to do with the Quality Settings.
In my project, the issue appeared between the default "Good" and "Beautiful" levels. So I slowly modified the Beautiful level to match the Good level with the project running and the Profiler open, and upon switching Shadow Quality down from High to Medium, I saw a jump from 25-35 fps to 55-65 fps. Anisotropic Textures also seems to reduce the amount of time for the GFX issue.
In short, from what I can see, lower your Shadow Resolution to Medium, and set your Anisotropic Textures to "Per Texture".
I know it's not optimal, but for performance sake, might be the only option right now.
i confirm that Cryztalfox temporary fix has eliminated the issue..
and i'd like to say that am using latest version of windows 7 pro.. so it's not an issue bound to windows 8
i dunno if nvidia drivers can cause such an issue, but i remember updated nvidia drivers many times.. so maybe gpu drivers involved in this??
any other idea i have try all i got 120 ms in my scène form gfx.waitforpresent
Every time this happens to me I put the computer into Sleep mode, wait a few seconds, and wake it up. I don't event close Unity. Everything runs fine then. In my case it seems to be a kind of problem with the graphic adapter that gets fixed when the driver is completely restarted.
Hey, Gfx.WaitForPresent is probably just similar to WaitForTargetFPS, their graphs seem to be mutually dependent. Meaning, regardless whether V-Sync is enabled or not, its just a waiting thread aka Idle. So if this value is at 99% your CPU isn't going to melt soon, it just got nothing to do.
The problems / test cases posted here, they all have an impact on CPU load and thus show an effect in Gfx.WaitForPresent. But you might reconsider before blaming this innocent value.
If its idle with nothing to do then what explains the performance hit?