Search Unity

Device.Present in profiler....what' the deal.

Discussion in 'Editor & General Support' started by iverson, Apr 19, 2011.

  1. iverson

    iverson

    Joined:
    Dec 27, 2008
    Posts:
    81
    Device.Present (Total) 32% (Self) 28%
    what's the problem?
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,378
    well, Device.Present may wait for vsync(vblank) - so it is just sitting there doing nothing ;-).
    Two main reasons are:
    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)
     
    Robert9552 likes this.
  3. iverson

    iverson

    Joined:
    Dec 27, 2008
    Posts:
    81
    the only one interface for frame rate is "Application.targetFrameRate" in unity,is it the key?
    as you're right,the frame rate is low,because there are 500 character in my scene,but they are invisible.
    i have to optimize 500 character in a scene.
     
  4. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,378
    well, that's sligtly different
    in QualitySettings there is a checkbox: Enable VBL (or something like that) if that is checked your fps will be aligned with monitor refresh rate (that's what VBL stands for). Try to disable VBL and profile once again
     
  5. iverson

    iverson

    Joined:
    Dec 27, 2008
    Posts:
    81
    thanks man, it worked.
     
  6. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,282
    I've got the same issue on my iPhone4. Only I don't have VBL on and the Device.Present function is consuming 81% of the frame! This pushes my frame rate to 10-15 fps even though the rest of the game is running in under 8ms...

    Any ideas?

    Could it be a shader problem or something on the iPhone?
     
    IgorAherne likes this.
  7. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,378
    you should have posted it in ios section
    on ios you have forced VBL
    and on later ios versions high Device.Present indicates that cpu waits for gpu (this counter will be updated in 3.4) meaning you are gpu bound
     
    IgorAherne likes this.
  8. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,282
    Thanks, this is what I thought.
     
  9. Xroft666

    Xroft666

    Joined:
    Dec 24, 2010
    Posts:
    24
    Hi, guys. From previous posts I understand that Device.Present is a process of waiting. But it slows my iPad from 5 to 15 fps and what am I suposed to do with it?
    Thanks )
     
  10. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,458
    @Antony Blackett and @WhiteDevil, did you guys learn anything new that could be added to this discussion?

    I can't figure out why my main menu screen is running at ~40ms per frame on an iPhone 4 yet on an iPod Touch 3GS I get 30 fps - and this is with having cut the screen right down to just a single button graphic on the iPhone 4.

    According to the Unity profiler the Device.Present is the culprit, but as mentioned above by @Alexey, I am GPU bound? I can't see how.
     
  11. funshark

    funshark

    Joined:
    Mar 24, 2009
    Posts:
    225
    I can't figure out what is the problem with Device.Present.
    I have a sluggish screen update in all my projects, with Vsync or not, and these "lags" are sync with the Device.Present component in the Profiler.
    Even with the simpliest scene : 1 cam and 1 cube with a transform updated per frame.
    It's annoying me since I thought it was something related to Camera and LateUpdate at the beginning..
     
  12. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,378
    device.present will be here because ios can't run faster then 60fps [or actually kFPS set up in AppController.mm] - so it basically shows you that you are waiting gpu to start new frame.
     
  13. andymads

    andymads

    Joined:
    Jun 16, 2011
    Posts:
    1,458
    I did find out something which helped me - I was rendering a couple of big invisible quads via a third-party plugin.
     
  14. SeikoTheWiz

    SeikoTheWiz

    Joined:
    Aug 1, 2011
    Posts:
    69
    We solved our biggest "device.present" issue by simplifying our shaders
     
  15. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,603
    The device.present problems you see here are caused by overdraw - stop filling the whole screen with transparent / ui and you are likely going much faster.

    iPhone4 / iPod Touch 4 / iPad1 have the same gpu as the 3gs generation but 4 / 5.2 times the pixel to render which the gpu is simply barely capable of doing -> alpha is a very bad idea if not used correctly, fullscreen effects are a no go and big particle systems will kill you too
     
  16. Allan-Smith

    Allan-Smith

    Joined:
    Feb 7, 2012
    Posts:
    52
    I've been struggling with this for quite some time... I've read this thread, and many others around the forums... but I just cant understand what is the problem.

    Here is my scenario: We are developing a 2D game, and the menu was running at 16 fps (with targetFrameRate set to 60) on the iPad 1. I profile it and Device.present is the villain. There is a lot of transparency on the menu, and 4 layers of background at different speeds, which adds up to a lot of transparency over the other. Anyway, reading about it, we made some changes, cut images into smaller ones, etc, and got to 24FPS, which is still bad. Then, after reading some more... we decided to do it other way... we modeled planes in the right shape for everything, so there is NOTHING transparent in the scene. The scene itself has 900 triangles with 8 simple objects, 4 different materials (all unlit), no overdraw (according to unity overdraw view), no scripts at all... and on the iPad 1 I still get only 45 FPS, which is good, but its not the possible 60 fps. On the profiler, the villain is still Device.present.

    If it were just for the menu, it would be ok, 45 is good, but I would like to understand why Device.present is still killing 1/4 of my fps for nothing, so I can improve other areas of the game that I am having the same problem.

    Thank you for your attention,
    Best regards,
    Allan
     
  17. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,167
    Have you turned off VSync? (I don't know if that's even possible on an iPad...)

    Assuming that VSync is on and the device is running at a 60Hz refresh rate, an average of 45FPS sounds like you're hitting every one-and-a-half frames (i.e. you just miss the first vsync and so present on the one after it, and then hit the vsync after that, repeat ad infinitum).

    It may also be that Device.Present is flushing buffers or something - a double-buffered GPU has to finish drawing to the backbuffer before it can present it as the front buffer, so if Device.Present is blocking then it may be because it's still drawing.
     
  18. Allan-Smith

    Allan-Smith

    Joined:
    Feb 7, 2012
    Posts:
    52
    Yep, VSync is turned off (at least on the quality settings)

    The real problem is that on the Menu we get 45 fps~, and on the game, we get about 45-48fps, but the enemies move as if they were lagged... its not a natural movement... initially they fall using rigidbodies and gravity until they reach the ground, and the fall is "laggy"... that is why I am concerned about this. This doesnt happen on any other device we`ve tested, the game runs at 60fps on iPhone 3GS... but feels laggy on iPad 1... =/
     
  19. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    837
    same here don't understand


    $7Fr3A.png
    $7Fr3A.png
     
  20. Denis Kniazhev

    Denis Kniazhev

    Joined:
    Apr 4, 2015
    Posts:
    2
    I have created a test 2D project which consists just of a camera and a sprite (200Kb png image). The sprite has a rigidbody and a script which rotates it when a user touches the screen. So the longer user touches the screen, the faster the sprite rotates. I run it on an average Android 4.2.1 device (Lenovo P780). This runs mostly 60 fps but the frame rate drops to 30 every 3-5 seconds for couple of moments. When this happens, Device.Present takes 80% of farme execution time.
    My project quality settins are set to Fastest, meaning that vsync (and a bunch of other stuff) is disabled. But yet the frame rate drops because of Device.Present.
    I have also tried Tower Defence example on the same device, with Fastest quality settings, and it runs on 35-40 fps, dropping to 15-25, again because of Device.Present.
    I have downloaded a couple of non-Unity, pretty intense 2D games from play store and they seem to run solid 60 fps on the same device. On the other hand, all Unity android games which I tried felt a bit luggish: playable, but definitely not 60 fps. I wonder if they all suffer from Device.Present too...

    Is there any solution for this Device.Present issue?
     
  21. hakankaraduman

    hakankaraduman

    Joined:
    Aug 27, 2012
    Posts:
    336
    I also have Device.PresentAndSync showing on profiler that takes much time to process.

    I have 40k verts in my scene and just 3 different material, they all use mobile/diffuse material and 256x256 compressed textures.

    I still have 28-30 fps either on s3 and galaxy tab 2014 edition.
     
  22. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    68
    I also have that device.present taking a maximum of resources (Total 86,3% Self : 85,6% !) on two of my scenes when I build and profile my game on Android. (with Vsync turned off or on, it doesn't change a thing)

    The first scene has only one canvas and 4 ameliorated buttons (meaning they are constituted of 4-5 UI layers). it runs, without animations at 20FPS. Quite ridiculous...
    The second scene uses a canvas too and a Pie from the "graph Maker" addon and run at approximately 30fps with one pie only and no animation. Ridiculous Too!

    The enigma is that I really don't underestand why those two scenes are doing that. My 4 other scenes, which display much more gameobjects run their 60fps.

    I'm working to understand why. I'll post here my eventual discoveries (if there is any)
     
  23. Guillaumzed

    Guillaumzed

    Joined:
    Mar 29, 2015
    Posts:
    68
    First solution :
    On one of my scene, it was an UI Image that was stretched which was doing the big mess.
    I found out that, if it was stretched (in any directions) with a bottom or a top NOT at zero, it was okay. But with all the values at 0 (left-right_top-bottom) : Boum, slow down "device.present" in the profiler.
    The solution in this case was to make a Sprite and a camera to replace my UI image that i wanted to stretch as a background image.

    It looks very much like a bug to me. I'll post that to the Unity dev team.

    For the other scenes, the problm seems different... still working on it.
     
    Last edited: Sep 12, 2015
  24. Peotor

    Peotor

    Joined:
    Jan 26, 2014
    Posts:
    2
    Here is what woked for me: I had more than one camera in scene, but while they all were enabled i had this "Perfomance hits", but when i disabled each of them except one i need at current moment, this problem disappeared.
     
  25. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    188
    Hey, I have the same issue here.

    Screenshot.png
    A game runs on iOS iPod 5th generation shows major performance impact caused by Graphics.PresentAndSync.

    As you can see, Camera.Render finished within 6ms so the rendering isn't the issue. Same game runs smooth on iPhone 6, only iPod causes the problem. I turned off VSync, change Graphics API from Metal to OpenGL ES 2.0 but no success(It looks like iPod only supports OpenGL ES 2.0 anyway)

    When I run the game on iPod through XCode, output panel shows these warnings :

    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD_DELTA' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - Pass 'SHADOWCASTER' has no vertex shader
    WARNING: Shader Unsupported: 'Standard' - All passes removed
    UnloadTime: 21.868374 ms

    On iPhone using Metal doesn't show these warnings. But I don't use Standard Shaders anyway, so... What can be the problem??
     
    IgorAherne likes this.
  26. Serhii-Horun

    Serhii-Horun

    Joined:
    Apr 12, 2015
    Posts:
    84
    Yeah, I have the same issue! Any solution?
     

    Attached Files:

  27. FastPaolo71

    FastPaolo71

    Joined:
    May 5, 2015
    Posts:
    2
  28. rlaghdejr

    rlaghdejr

    Joined:
    Dec 6, 2013
    Posts:
    1
    To me it was my custom shader (for tutorial screen with rounded-box holes) causing it (around 60ms of it).
     
    Last edited: Jan 10, 2018
  29. laurG

    laurG

    Joined:
    Jun 1, 2017
    Posts:
    6
    Apparently this happens because of CPU related performance issues. In my case, I was using a SphereCast on Android in the FixedUpdate of a single object. I removed that and I got 60 FPS.