Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

(Case 1082192) Massive performance hit due to UI

Discussion in '2018.3 Beta' started by TokyoWarfareProject, Sep 16, 2018.

  1. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    I'm having as many other the issues of broke prefabs so I did manually "fix" the minimun needed to run so I could give it a rough test to the beta and see if I could see something else "broken".

    I noticed game was running super low on editor, on 2018.2 for tested setup I should be gettin like 115 fps, I was getting 30 or so, launched profiler and saw this:

    upload_2018-9-16_20-38-47.png

    Dissabling UI gameobject "solved" the issue by setting the it back to teh 120 fps range.

    mmm Any clues? anyone noticed something similar?

    Also, what is the playerloop/editor loop thing?, Editor loop would be the old editor overhead?.
     
  2. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    Ok, dug a bit deeper,

    For some reason, it is taking a hell of effort to render text. it does not matter if its dynamic or stati text. My UI is mainly text so may be if there where mor images it would be them...

    As I've uploaded the project to a server I will wait a bit and see if anyone suggest something and if not I'll report a bug and link to the project for repro.
     
    Last edited: Sep 16, 2018
  3. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    Ui enabled
    upload_2018-9-16_21-3-4.png

    UI Dissabled
    upload_2018-9-16_21-3-24.png
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,574
    Could you build a Player and profile if you see a performance regression there as well?
     
  5. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    Same:
    upload_2018-9-17_9-32-10.png
    This is the profile for the build
     
    Peter77 likes this.
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,574
    How does the "Canvas.SendWillRenderCanvases" compare to earlier versions of Unity? In 2018.3 it shows 3.19ms, how fast is it if you repeat the same test with 2018.2?
     
  7. DoctorShinobi

    DoctorShinobi

    Joined:
    Oct 5, 2012
    Posts:
    219
    Hey. Are you perhaps making a change to the layout every frame? If I remember correctly changing your UI causes the entire canvas to build, so if you have a lot of objects this can cause a lag spike. Are you doing something to the text every frame? can you show us the your UI hierarchy?
     
  8. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    I took an screenshot of it running in editor: 2018.2.0f8 (I was using f2 till today but it runs same), but you can se canvas hit even in editor is small, vs 14ms of the 2018.3 editor.
    upload_2018-9-17_15-47-4.png

    //-------------------------------------------------------------------
    Yes I'm updating txt every frame, its the timer up in teh middle. I thought of it also, but dissabling just the timer seemed not to make a dramatic difference.
    I'll try to see if I've any kind of Update canvases called accidentally, but I believe that should also clog the profiler in 2018.2.
    Layout wise not sure what changes caould cause full refresh, but yes as the milisecs change value the text move a little, but as I said, it won´t skyrocket from 30 to 100 just dissalbing timer, tonight I'll look again in depth to see if I manage to catch cause and see if its fixable or should be reported. The strange thing tho is I'm the only one, but may be the prefabs issue is holding many (if not all) ppl to port their projects and allow testing for such things.


    upload_2018-9-17_15-59-27.png

    upload_2018-9-17_16-0-31.png
     

    Attached Files:

    Last edited: Sep 17, 2018
  9. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,127
    If this used to work, then please submit a bug report for it. If possible, with the project attached. You can also share read access to your repository, instead of uploading the project through the bug reporter.

    Edit:
    I see you already uploaded the project in a prior report. In that case please refer to that case in the new report.
     
  10. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    Hey, sure but I believe this is the same issue
    https://forum.unity.com/threads/case-1081996-ui-performance-regression.556801/
    I posted in there notes for your team to reach out my project, that is already accesible to your staff for another issue.
    I can send you PM with acces data if that eases things.

    edit: OK

    edit2 Unity QA notified me this to be same as
    (Case 1081996)
     
    Last edited: Sep 19, 2018
  11. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,127
    Thanks a lot! Really appreciate your help.
     
  12. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    @TokyoWarfareProject So i looked into your issue as well because your perf loss didn't make sense to me in terms of the other case.

    So "good" news, the issue is due to your scene set up. There is one canvas object that has 2 CanvasScaler component on it. Remove one and all should go back to normal. There should be no case where both are required as they write to the same value on the Canvas, and that was exactly the cause of the issue.

    In pre 18.3 the CanvasScaler would track the "previousScaleFactor" locally and only write to the canvas if the local value changed. In 18.3 and beyond this check has moved to the Canvas itself as it fixes some other bugs around the CanvasScaler not setting values at proper times. What happens now is both CanvasScallers on this Canvas are fighting with each other. The first is set to ConstantPixelSize and sets the ScaleFactor to 1. The second is ScaleWithScreenSize and sets the ScaleFactor to 0.47. The canvas gets the first value sees its different and sets the value then sends out the appropriate message. That message is OnRectTransformDiemensionsChanged which tells all children elements that they need to rebuild both the Geo and layout. In your case changing the geo is expensive as you are using the Outline component on your text thus you saw a improvement when you removed your text. Its ok for one off updates but constant its noticeable.

    I'm not sure why we ever allowed multiple of the CanvasScaler component so i've added the tag to disallow that but i dont think it removes any current duplication so you'll have to do that manually.

    Hope that helps.
     
  13. TokyoWarfareProject

    TokyoWarfareProject

    Joined:
    Jun 20, 2018
    Posts:
    811
    Indeed AWESOME news!!! I likely accidentally droped that second canvas and overlooked as the canvas object is not something I modify.

    I'll check the performance hit of the outlines, still I see a bit of an overkill impact they where having even if it was twice. Probalby that is further solved by now. This, and the aparently fixed preba import paves the way to proper beta testing for me. I badly whant to test 3.4.2 physix as the experimental 3.4.1 editor was showing waaaaaaaaaay more stable behaviour with joints even at double the timestep.

    ------- THANK YOU -------
     
    LeonhardP and phil-Unity like this.