Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

UI performance issues

Discussion in 'UGUI & TextMesh Pro' started by samuelk, Mar 23, 2015.

  1. samuelk

    samuelk

    Joined:
    Feb 7, 2014
    Posts:
    5
    Greetings!

    We're experiencing some major performance problems on mobile (and PC) due to the UI system using Unity 5 (and previously 4.6.3).

    We're losing about 30fps on iOS (iPad mini and iPad 3 retina) because of our HUD which is comprised of only a very few elements. Here's a screenshot of it:


    All the UI-elements (except for the text) come from one image atlas which I created in photoshop.

    When I animate anything on the UI, I lose about 200-300 fps even on a decent PC (i7 860, gtx 560 ti II), dipping from around 900 to 600-700 fps, sometimes even lower. The animations are very simple, e.g. a flashing the star in the upper right corner when the player picks up points, sliding a text notification to the screen when mission objective changes, etc. Notice the fps without the UI:


    Then there's a problem with world canvases. As the player picks up something of value, we throw a pooled prefab canvas on the spot which has three UI elements: a world canvas, a star sprite, and a text element. Doing this halts the whole application on iOS for about two seconds and causes some major hickups for a few seconds after that. It's also visible on a PC:


    Notice the Canvas.SendWillRenderCanvases() cpu usage and Canvas.BuildBatch.

    The 5,300 points and star is a world canvas which is animated to rise up slowly and fade away. Also, the "You found the keycard!" -text appears from the top of the screen and the star on the right corner flashes. Nothing too complex here but still getting a horrible performance.

    So, I'm here to inquire is there something terribly wrong in the way we're using the UI or could this be an issue related to the UI system? In any case, are there any further optimizations or tricks to use here to avoid the overall performance hit and hammer down the huge Canvas.SendWillRenderCanvases() spikes?

    Cheers!
     
    super77gg likes this.
  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    That is a concern, one that should be raised in a bug report using the Unity Bug reporter in the editor.
    @Aras / @phil-Unity any ideas on this one.

    However personally, I would not use WorldSpace canvases for that kind of display. Better to approximate the position and rotation in 3D and then use a Screen Space - Camera canvas to draw it in perspective.

    If you check @Adam Buckner 's slider live session (at about 56 mins), he breaks out in to this implementation at the end with his awesome Elite Dangerous space map :D
    http://unity3d.com/learn/tutorials/...ing-archive/creating-scroll-lists-at-run-time

    Oh and awesome looking game btw, can't wait to try it out!
     
    samuelk and crushhh like this.
  3. Vibs_appit

    Vibs_appit

    Joined:
    Feb 16, 2014
    Posts:
    53
    I had similar problem. The text on world space canvas. If you have PixelPerfect enabled, try disabling that. This is also a case with scroll rects containing text elements. Basically, if you have moving text, make sure the canvas is not set to pixel perfect, because that causes the reload and rebuilding of entire canvas which you definitely don't want every frame.
    I had the Canvas.SendWillRenderCanvases() hit of 53ms which is insane. I have large number of elements in scrollrect, almost all with a text element. I spent 5-6 hours today to locate the issue and I found the culprit after a suggestion on one of the forums (Can't recall). Messy stuff. Unity needs to put a decent do's and don'ts of UI and GI in docs.
     
    Last edited: Mar 23, 2015
    samuelk and SimonDarksideJ like this.
  4. crushhh

    crushhh

    Joined:
    Mar 22, 2015
    Posts:
    12
    SimonDarksideJ likes this.
  5. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    No worries, there is a lot of good stuff out there. The trouble is finding it :D
     
  6. samuelk

    samuelk

    Joined:
    Feb 7, 2014
    Posts:
    5
    Is there a specific reason for not using worldspace canvases for this kind of thing because we're also thinking of making dialog system the same way? We used position approximation earlier with DF-GUI so it's not a big deal to go back to it though. :)

    I'll check out that video, thanks!

    Thank you! We're hoping to release a public beta later this spring.
    Btw, the UI Extensions project seems really cool, I've gotta check it out. There's many effects I wish the default UI would have.

    Thanks for the tip! The performance is definitely better now. With all the optimizations we've done during the past few days, the game is now running somewhat stable 60fps.

    Cheers!
     
  7. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,685
    @samuelk World Space canvases work best for fixed elements, such as dialogues and monitors and such.
    If you use them repeatedly, then use a pool of the same definition (as you would do with anything else). Only use fixed worldspace canvases for permanent things, like a big monitor on a wall for instance.

    For character diaglogue, I would have just a couple of WorldSpace Canvases (or even just one if only one party talks at a time) and just shift it round the scene like any other GO. Have to simply treat it like any other GO, ignoring the fact it is UI.

    Hope that helps
     
    samuelk likes this.