Search Unity

New UI costing me 20+ fps.

Discussion in 'UGUI & TextMesh Pro' started by Deleted User, Dec 9, 2014.

  1. Deleted User

    Deleted User

    Guest

    Fixed: separate outside windows/UI elements into separate canvas's, hide when not on screen!!..(duh)

    I am running my project in parallel, one with the new 4.6 UI, One with the UI Toolkit open source UI.
    I noticed a steep decrease in my frame rate,.
    So made a duplicate project and re-created my interface, using UI Toolkit . Same scene, etc..

    New 4.6 UI. (approx 40 fps) - WIP


    New 4.6 UI. (approx 70 fps) - WIP - Hidden Outside Windows!!


    UI Toolkit (Approx 80 fps)- WIP still arranging buttons, etc.


    I am driving all UI elements, the same way,Knobs, Sliders, etc..

    I just thought I would share this benchmark..

    (4.6.1 I will gain another 5-10 fps?? :)


    FYI


    Patrick
     
    Last edited by a moderator: Dec 9, 2014
    tnbao91 and rakkarage like this.
  2. mog-mog-mog

    mog-mog-mog

    Joined:
    Feb 12, 2014
    Posts:
    266
    I usually expect native UI to be faster than external assets. I hope future updates will improve on performance.
     
    rakkarage likes this.
  3. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Hey There,

    Are you using one canvas for each element?

    Regards,
     
  4. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Yeah if you're on pro (which it appears to be true), could you do some CPU profiling on the UI and find out where you're finding the biggest bottleneck? Especially, as it relates to UIToolkit's performance in the same area? It looks like there are considerable more draw calls on the uGUI layout as well.

    Hopefully, the more posts there are like this the more likely that we'll get some more advanced options with the UI backend that we can enable to improve performance (maybe at the expense of complexity). The overheads associated with uGUI are too high compared to other UI solutions.
     
  5. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    It's worrying that there's so many performance questions/concerns over uGUI at the moment.

    I was hoping/expecting that a native UI system would naturally outperform anything that was building meshes (often every frame) in C# scripts (e.g. NGUI). As a mobile developer, that is the biggest reason for wanting to use uGUI.

    In this case, are your textures actually atlased? (have you assigned them packing tags and checked the Sprite Packer?)
     
  6. Breyer

    Breyer

    Joined:
    Nov 10, 2012
    Posts:
    412
    In addition you should test standalone player rather than in editor, performance drop might be caused by internal editor stuff in ugui which external tool havent that much. Last, u have 4.6p1 version? This patch contain several optimization
     
  7. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    I believe many devs still didn't get to the performance optimization stage with the new games they are building on new UI. We are among few devs that are actually trying to raise the awareness of slow performance of new UI (we started our game in april using beta 6 or 7).
     
  8. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    Seems to be a lot more draw calls using uGUI, I suspect that is a big part of it. Are you using World Space or Screen Space canvas?
     
  9. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Did you try to measure the actual performance outside of the Unity Editor?
     
  10. Deleted User

    Deleted User

    Guest

    Nope, 1 canvas, screen space..(I can get everything here(except my map mask - tilted graphic)

     
    rakkarage likes this.
  11. Deleted User

    Deleted User

    Guest

    no, I actually have not built my new version, in 5 months..(I probably should!!)

    My major issues with the new 4.6 final/RC3 - UI, OVERHEAD!!!

    UI Toolkit Builds the UI Once...Unity UI Builds it every frame...that is the bottleneck..



    SpritePacker/CanvasScaler..Broke my project (had to start over from a back-up, )



    I (had) to purchase TexturePacker Pro, turned off SpritePacker and my project was back to normal)
     
    Last edited by a moderator: Dec 9, 2014
    rakkarage likes this.
  12. Deleted User

    Deleted User

    Guest

    I am just going to use a hybrid, UI Toolkit in active game play screens, keep my 60 fps!!, and Unity UI for all other screens, I purchased TexturePacker, I can have 2 sprite atlas, 1 legacy UI / 1 Unity UI...

    p-
     
  13. Deleted User

    Deleted User

    Guest

    you are right, I posted my actual canvas, unity is drawing calls, for all outside elements - why?? it defies logic..
     
  14. Deleted User

    Deleted User

    Guest

    Try my Hybrid approach: active game screens - UI Toolkit, static menus Unity UI..(I still have 10-25 flying and ground AI) - I need to have a stable 60 FPS at his stage..period

    Keep the speed..at all costs!!! ;-)

    p-
     
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    As I understand it, you should be using a canvas per dynamic element. For things that don't change, they should be on one canvas.

    Otherwise it rebuilds the entire mesh if you change one tiny little thing.
     
    Marco-Sperling and Dantus like this.
  16. Deleted User

    Deleted User

    Guest

    You are correct!! I just did not think I could build little canvas's (is that the plural?)
    and makes a lot of sense, unity sees the canvas as a whole entity at run time, and since I have animations, buttons with events, the event system and canvas/canvas scalar has to keep track of them..

    That is why I tried to phrase this post as informational, rather than any form of derogatory criticism..

    Just your 'fresh perspective' made a big difference..Thanks
    (I may have just wasted 2 days with the UI Toolkit re-build..arghh)

     
  17. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    We currently don't do any culling of objects its on our road map and i have a half baked implementation that need further refinement before it can be released.


    If things change it needs to rebuild everything atm. you can have as many canvas's as you want and even nest them to maintain the anchoring. As a note a canvas is like a NGUI panel where each one is its own set of draw calls. but the benefit of having less to build sometimes greatly outweighs the draw call issue.

    Hopefully fixes for this are coming shortly.
     
    Marco-Sperling likes this.
  18. Deleted User

    Deleted User

    Guest

    I have confidence and patience, I can get my base player/skydome and UI/dials..running at 80 fps @ 1280X800, in the editor, with my tab attached...I am not complaining!...as a graphic designer,the new UI opens doors...
    these tools are great!!
     
  19. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    ....that's surprising to hear.

    So will elements in a nested canvas not be included in the parent canvas' drawcalls?

    Is there somewhere that explains all this? I don't remember the tutorials etc mentioning this at all.
     
  20. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    I am happy to hear that things are going well. I have been working on a project at work that uses 100% ugui for all elements. We started back in early beta and fought a ton of performance issues along the way ( Damn you cached text generator! ) but almost at the point of release we don't have many Unity issues. The only thing we fight with is text (which our game is made up of). As a result we use Text mesh Pro. It's a really good asset even when in beta.
     
    Stephan-B likes this.
  21. puppeteer

    puppeteer

    Joined:
    Sep 15, 2010
    Posts:
    1,282
    That's a very important point by hippocoder, which should be emphasized more by Unity IMO.

    So, basically each health bar you have in the game should have its own canvas, and a menu can share a single canvas.

    What happens if we mix regular sprites/textmesh with the newUI, for example if I want to make a health bar with numbers appear over the head of enemies ( I don't know how to achieve this with the newUI elements so I use pre-4.6 sprite/textmesh ). How much does it affect performance?
     
  22. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    Please update us if p1 changes fps at all.
     
  23. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hi, we have a whole bunch of performance optimisation plans as we move forward, so things WILL get better. We are not happy with dynamic elements rebuilding the whole canvas and all that (so nasty) and we will address this when we can.
     
  24. Deleted User

    Deleted User

    Guest

    I am finishing up now..upgraded to 4.6.1..I am not seeing anything, as far as dramatic increase/decrease in frame rate..but now..my level is still not fully optimized, and I may need to add a 3D Canvas for inside my cockpit..transfer dials?

    I am publishing for android, so I had to dump Drop Shadows, outer blurs.on my UI elements.That was 5 FPS, creating more canvas elements, and disabling the canvas component when off screen, another 10 FPS..so in the end I should get a pretty playable game, considering what I am trying to do..full 3D photo realistic flight simm - with combat AI..

    getting closer..


    but this just looks stupid...


    everything but the radar should be easy..But with my huge map, 15 flying AI, all firing..45 fps..before any, occlusion culling,LODs, etc - without optimization, pretty much where I want to be...

    I will run some benchmarks today..

    p-
     
    Last edited by a moderator: Dec 11, 2014
  25. Deleted User

    Deleted User

    Guest

    As a developer, here is what I know
    a). This is new and evolving technology.
    b).Your team is under staffed and under impossible deadlines.
    c). What you have accomplished, during the 'Beta Hell' Year..is simply amazing.

    Miracle workers asked to do the impossible!!

    I highly suggest everyone on the UI team get a huge BONUS this year!!
    New CLK's for All!, just pick your color...



    p-
     
  26. Saxi

    Saxi

    Joined:
    Jun 28, 2013
    Posts:
    381
    They are like 4 years late on the UI.
     
    kablammyman likes this.
  27. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    lol, one day i'll write a tell all no holding back story of how the Unity UI was developed.
     
    AcidArrow, BMayne, Stoven and 5 others like this.
  28. Deleted User

    Deleted User

    Guest

    ok..maby I don't know!! :-(...

    but..I did get my UI to 3 Draw calls (1 is the joystick) and flying with my mesh terrain @ 60 FPS(give or take) 1280X800 and can be improved a lot....that's it for this chapter...except how crappy my dials have become.

    .thanks for all the help!!



    Patrick Force-
     
  29. Alan47

    Alan47

    Joined:
    Mar 5, 2011
    Posts:
    163
    Now that would be an interesting blog post to read. Please do!
     
  30. daklab

    daklab

    Joined:
    Nov 24, 2013
    Posts:
    27
    I look forward to that.

    @Tim C For the current state of uGUI, what are the tips/tricks or things to be most aware of when using the new UI? For example @hippocoder suggests using a canvas per dynamic element, is this a best practice?
    1. If it doesn't exist already (if so, where can I find it?), could Unity outline the dos/don'ts and best practices of uGUI regarding performance?
    2. Is there a roadmap (preferably detailed) for the UI that Unity can share publicly? I'm interested in both future additions but more importantly what is planned to actually improve performance.
    I was lead to believe the uGUI was going to be superior to other Unity UI solutions regarding performance and this doesn't seem to be the case :( I imagine the system was a give/take for making it easy-to-use within the editor and raw performance trade-offs. Great work on the final product btw, I'm just curious about how things will look moving forward.
     
  31. Pix10

    Pix10

    Joined:
    Jul 21, 2012
    Posts:
    850
    Canvas groups themselves don't seem to impact performance - that I've noticed to date -, and without culling (honestly, I'm completely stumped that we got a release build UI without culling after all these years), logically grouping of elements into canvases makes it a lot easier to manage a complex UI with your own culling solution, especially if you have a lot of on/off screen transitions.
     
  32. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    Can you tell us which future update might have any performance related tweaks? I'm not talking about minor ones, but something that might have significant performance gains compared to what we have now. I understand that it's hard to tell exactly but anything would be great - like 4.6.3 for example or let's say "a month from now". Thanks in advance for answer (if we ever get one :))
     
  33. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'd love that. Some of the best stories are the ones nobody can tell but come out anyway at the bar during gdc or whatever, true in the trenches fun.
     
  34. Chetim

    Chetim

    Joined:
    Jan 30, 2013
    Posts:
    12
    Had a similar experience with a spike in lag whenever I updated score. Does updating one UI element in a canvas still update the whole canvas? That didn't turn out the main culprit in the end anyway. What fixed it for me was changing the score sprite font from Dynamic to Custom with just the numbers. My issue was that I was using a very large font (150) on iOS, so each time it updated the score it had to process a huge texture. Just wanted to add that incase anyone else with the issue finds this thread like I did.
     
  35. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    A parent updates all it's children, a child does not update it's parent.