Search Unity

Unity 5.2: UI performance seems much worse

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by graspee, Sep 9, 2015.

  1. graspee

    graspee

    Joined:
    Jun 1, 2014
    Posts:
    8
    I have a roguelike game: it's 2D, uses pixelart sprites and is written entirely using blits to the UI in unity.

    Because I heard that 5,2 was going to give better performance through better batching I took an fps count by turning off vsync in the quality settings and running the game in the unity editor. I was getting about 330 fps.

    After upgrading to 5.2 I tried it again and was only getting 130-160!

    Is there something I might have missed or has UI performance actually got worse in 5.2?

    edit: I admit though, I was using just the start button in unity itself, I wasn't using "build and run". I'm trying to test the game under both unity versions right now but I'm suffering from another problem: that 5,2 doesn't seem to go full screen to 1280x720 anymore but stays in desktop res.
     
    Last edited: Sep 9, 2015
    TheFranS and MrEsquire like this.
  2. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
    I don't know if its the performance in my case I use many buttons in the bg and now they are not responsive like before in the editor. On an device I have no issue at all.
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,140
    All our tests have showed the UI is now much more performant. If you're experiencing something different a project would help (i.e. report a bug and post the bug number)
     
  4. meapps

    meapps

    Joined:
    May 21, 2013
    Posts:
    167
  5. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    5.2 is performing alot worse than 5.1 due to a number of bugs... The switch to meshes in 5.2 has caused a memory leak everytime a mesh is updated / changed...

    https://fogbugz.unity3d.com/default.asp?727000_jv3r93cq7812oqdv

    on the plus side, once these minkies are fixed, the UI will be performing alot better! Batching & Meshsupport has made a huge difference to our drawcalls & vertex count numbers! I'm looking forward to the next few patches! Keep up the good work UI Team :)
     
    super77gg likes this.
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,140
    We have a fix on the way to a release branch that should fix the performance issues with using the mesh. Not sure when it will get released though :).
     
    super77gg and wikmanyo like this.
  7. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    Hopefully it will be soon, the mesh leak issue makes 5.2 unusable in its current state...
     
  8. Angelbuzon

    Angelbuzon

    Joined:
    Aug 8, 2014
    Posts:
    5
    Screenshot_2015-09-16-20-27-45.png Screenshot_2015-09-16-20-51-38.png


    My app (which uses much ui and scroll) on unity 5.1 have 40-50fps on unity 5.2 only 18-20fps.
    I can not understand where is the improvement of this version.
     
  9. super77gg

    super77gg

    Joined:
    Sep 25, 2014
    Posts:
    46
    We are getting degraded performance with the new UI as well - along with a lot more artifacting on masked elements. Hopefully the next patch fixes it! Excited to see if we get increased performance over 5.1 builds as we use the UI extensively in our project.
     
  10. topaz7

    topaz7

    Joined:
    Dec 15, 2012
    Posts:
    76
    Need help here. All of the players are complaining that their FPS has worsen after the update to 5.2 and it seems like GUI is the issue.
     
  11. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,093
    As we've said in this thread and others, there are fixes on their way for a patch release soon. Issue was related to some dumbness in our scroll rect calculations. The perfomance improvements in 5.2 are in the batching (c++ side), not in the UI system itself.
     
  12. howettl

    howettl

    Joined:
    Nov 18, 2013
    Posts:
    1
    The problem seems to still be happening with the patch release that went out on Friday morning (Sept 18). Is the fix you mentioned still on its way?
     
  13. andsee

    andsee

    Joined:
    Mar 20, 2012
    Posts:
    88
    Just tried Unity 5.2.1 released Sep 22nd and I have the same 20% frame rate loss (iPad2) as 5.2.0p1 over 5.1.3. across a range of our screens which do not use scrollview.

    Look forward to the patch with the fix so that I can check to see if my issue is the same as the one you've identified and fixed or if I need to sort out a repro project.
     
  14. Fajlworks

    Fajlworks

    Joined:
    Sep 8, 2014
    Posts:
    344
    I can confirm Unity UI performance degradation, when I'm instantiating GameObjects with UI sometimes the screen freezes, in most cases just crashes the editor. Profiler shows this:


    0.67gb in Font.InvokeTextureRebuilt_Internal() ¬_¬
     
  15. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    Just go back to 5.13 , unity 5.2 is utterly broken.
     
  16. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    You tried 5.2.1p1?
     
  17. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    I just downloaded 5.2.1p1 , and it seems they have changed OnPopulateMesh(Mesh m) to OnPopulateMesh(VertexHelper vh) - 5.2 is just not worth bothering with , no mention in the docs about this, no update of the UI source code on bitbucket... what a total joke.

    Get your act together Unity. Quit messing us around with undocumented STUPID changes - that vertex helper class sucks, I deliberately didn't use it when I upgraded to 5.2 because of all the memory allocation, and now you force us to use it? Keep things STANDARD , use a MESH.

    I'm sticking with 5.1 , giving up completely on 5.2 until they stop messing us around.
     
  18. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thanks for the thoughts, I agree about sticking to 5.1.x and waiting for the 5.1.4 final release before fully upgrading from 4.6x..Seem anyone on the forums who complains or trys to get some answer from Unity gets number of unity fan boys on his back..Althought many things are done right, many are slow progress also.. All i got say is there was a poll in the beta section should 5.2 be released and majority vote was noo until stable..
     
  19. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    5.2 is BETA - the UI is utterly broken. I've wasted enough time beta testing it already.

    Making OnFillVBO obsolete and replacing it with OnPopulateMesh fair enough, it was required for the mesh switch over. But making OnPopulateMesh obsolete two weeks later is just plain messing people around.

    I feel sorry for the people who have to keep their store assets up to date, it must be a nightmare for them.
     
    MrEsquire likes this.
  20. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    Since TextMesh Pro is closely tied into the Canvas system, Unity 5.2 has been an interesting ride thus far. I am certainly looking forward to the next few patches and hoping Unity is done with API changes.

    Whenever Unity makes significant API changes, as Asset Developers we are simply caught in the crossfire. It is unfortunate that some users don't realize how these changes affect us. Too often they presume the fault lies with the Asset developer when in reality we have to wait for patches like all other users to address the issues affecting our products.

    It will take a few patches for Unity to iron out those issues in Unity 5.2 but in time we will get there. It is just unfortunate the migration to Unity 5.2 hasn't been as smooth as previous releases.
     
    andsee and MrEsquire like this.
  21. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    I suspect TextMeshPro is about to get a whole lot slower with 5.2.1p1 due to the VertexHelper bottleneck.
     
  22. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    I use OnPopulateMesh (Mesh) for Vectrosity and wasn't aware of any changes since I didn't download 5.2.1p1. I don't use VertexHelper for anything and would appreciate it if this wasn't messed with. That is, keep it as Mesh please.

    --Eric
     
  23. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    I don't use OnPopulateMesh and whatever its replacement is. I currently use SetVertices() which is temporary while I convert to using SetMesh(). So I should be able to avoid using the VertexHelper stuff completely.
     
  24. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    Interesting... So you aren't using a maskable graphic as your base for text mesh?
     
  25. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    Too late :( they already messed with it! OnPopulateMesh(Mesh m) is marked as obsolete in 5.2.1p1 - its a horrible change.
     
    Lermy-KefSensei likes this.
  26. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    I mean for Unity 5.2.2. Patch releases haven't gone through the usual QA process.

    --Eric
     
  27. wikmanyo

    wikmanyo

    Joined:
    Nov 17, 2012
    Posts:
    49
    Ah, you have an advantage! :) hopefully its not too late to get the vertex helper changed reverted... It's introduced a huge CPU bottleneck... Outlining a paragraph of unity text now takes 2.5ms on a 4.6ghz skylake CPU lol
     
  28. Lermy-KefSensei

    Lermy-KefSensei

    Joined:
    Apr 21, 2015
    Posts:
    7
    I was using a Gradient script previous to 5.2.1p1 to make my fonts and widgets to look nicer and now I can't find a way to make it work since the method public 'virtual void ModifyMesh(Mesh mesh)' on BaseMeshEffect is not getting called at all.

    And how am I suppose to update the mesh inside the method:
    public abstract void ModifyMesh(VertexHelper vh);

    without a reference to the mesh it self, I did not found a method to do this at all.

    If anyone has found a way to do this please share, I will really appreaciated!
     
  29. Lermy-KefSensei

    Lermy-KefSensei

    Joined:
    Apr 21, 2015
    Posts:
    7
    They updated the documentation refering to the VertexHelper class, and even in the example they are given they call the method FillMesh :

    vh.FillMesh(mesh);

    but there is not mesh reference nor an access to it here:

    Code (CSharp):
    1. public interface IMeshModifier
    2.     {
    3.         //
    4.         // Methods
    5.         //
    6.         void ModifyMesh(VertexHelper verts);
    7.  
    8.         [Obsolete("use IMeshModifier.ModifyMesh (VertexHelper verts) instead", false)]
    9.         void ModifyMesh(Mesh mesh);
    10.     }
     
  30. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,140
    Do you need the mesh itself or just the vertex data? If just the data vh.GetUIVertexStream(List<UIVertex) will give you the data.
     
  31. Lermy-KefSensei

    Lermy-KefSensei

    Joined:
    Apr 21, 2015
    Posts:
    7
    The VertexHelper does not hold a reference to the mesh by itself, is just a copy of the mesh data that I cannot access anymore, I need to call FillMesh to get the job done. This is how my script is working prior to 5.2.1p1:

    Code (CSharp):
    1. public override void ModifyMesh(Mesh mesh)
    2.    {
    3.         if (!this.IsActive())
    4.             return;
    5.  
    6.         List<UIVertex> list = new List<UIVertex>();
    7.         using (VertexHelper vertexHelper = new VertexHelper(mesh))
    8.         {
    9.             vertexHelper.GetUIVertexStream(list);
    10.         }
    11.  
    12.         ModifyVertices(list);  // calls the old ModifyVertices originally used on 5.1
    13.  
    14.         using (VertexHelper vertexHelper2 = new VertexHelper())
    15.         {
    16.             vertexHelper2.AddUIVertexTriangleStream(list);
    17.             vertexHelper2.FillMesh(mesh);
    18.         }
    19.    }
     
  32. Lermy-KefSensei

    Lermy-KefSensei

    Joined:
    Apr 21, 2015
    Posts:
    7
    Please tell me there is a workaround for this, if not could we have this for p2? Our game is entirely done on 2D UI and without gradients the game is just totally flat. Please keep us posted, since we will not be able to upgrade to a new version without this fix. Thanks Phil.
     
  33. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,140
    well by the looks of your code you could just change the ModifyMesh(Mesh mesh) to be ModifyMesh(VertexHelper verts) and do the same thing without the FillMesh. I'm not sure i'm following what your exact issue is. Maybe PM me and we can take it offline.
     
  34. exawon

    exawon

    Joined:
    Dec 9, 2013
    Posts:
    12
    Hi, Lermy.
    I believe the replacement below is what you are looking for.
    Code (CSharp):
    1.  
    2.         //public override void ModifyMesh(Mesh mesh)
    3.         public override void ModifyMesh(VertexHelper vh)
    4.         {
    5.             if (!this.IsActive())
    6.                 return;
    7.  
    8.             List<UIVertex> list = new List<UIVertex>();
    9.             vh.GetUIVertexStream(list);
    10.  
    11.             ModifyVertices(list);
    12.  
    13.             vh.Clear();
    14.             vh.AddUIVertexTriangleStream(list);
    15.         }
    16.  
     
    Lermy-KefSensei likes this.
  35. Lermy-KefSensei

    Lermy-KefSensei

    Joined:
    Apr 21, 2015
    Posts:
    7
    Hi exawon, thanks for posting the solution! This is exactly what it makes this works. Thanks a lot!
     
  36. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    81
    Was this mesh leak ever fixed in 5.2? I'm on 5.2.3p3 and it is still occurring. I can't upgrade to Unity 5.3 on this project....

    I see it was fixed in Unity 5.2.1p1 but it's clearly still happening on 5.2.3p3 (the final patch release). I have a very simple UGUI dialog that is created & destroyed and it leaks 5 meshes each time. I'm measuring via the Memory section of the Profiler.

    5.2.1p1 release notes:
     
    Last edited: May 30, 2017
  37. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    81
    I was creating a test project with this bug to submit to Unity but I couldn't actually reproduce it with just a canvas + panel + image. Turns out the mesh leak is actually with Text Mesh Pro UGUI. In the Text Mesh Pro UGUI code, it seems like a simple case of creating a mesh and not destroying it, so the fix was trivial. No more mesh leak! Sorry to blame you, Unity =P
     
  38. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,320
    Can you provide more information on this? What version of TextMesh Pro are you using? I would like to make sure this was or is addressed on my end.
     
  39. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    81
    I'm not actually sure which version we're using but it was before your refactor of the inline graphics. I think it's pretty old.

    In TMPro_UGUI_Private.cs Awake() it's doing "new Mesh()" but then never destroying that mesh (from what I can tell). I just made it destroy the mesh in "Destroy()".

    The regular non-UGUI version already didn't have the bug.

    Maybe something else was expected to destroy the mesh and my fix wasn't actually correct or will break some kind of caching? It definitely fixed the mesh leak though.
     
  40. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,320
    I have made a lot of changes since Unity 5.2 especially in those areas due to how 5.2 changed a whole lot about how geometry was generated and handled for the Canvas System. These leaks should have been addressed in that time frame or in subsequent releases around that time.
     
    tayl0r likes this.