Author Topic: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate  (Read 18089 times)

quickfingers

  • Guest
Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« on: October 20, 2013, 06:25:18 AM »
getting some really severe performance spikes since using ngui 3.



So far it seems the spikes appear when widgets colors fade in and out and/or when widgets are moved in an Update.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #1 on: October 20, 2013, 03:58:43 PM »
What happens in your ScrollingTextArea object?

quickfingers

  • Guest
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #2 on: October 21, 2013, 04:45:06 AM »
The panel which takes up all the frame time seems arbitrary...
If I disable the ScrollingTextArea panel then the next panel in the queue lags in the same way.

quickfingers

  • Guest
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #3 on: October 22, 2013, 09:16:29 AM »
I think it may have something to do with using dynamic fonts as testing another scene with only bitmap fonts and it seems fine.

I am also using Unity 4.3. beta so there may be issues with the gc

NaxIonz

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #4 on: October 22, 2013, 02:01:33 PM »
Yeah, I noticed this as well. As soon as you let go of dragging something..... boom lag spike!

Some of our outsource testers on some old devices are saying our scrolling menu is almost unusable now :-(

I figured it was because we added some more widgets to that panel, so I told our producer that we needed to allocate time to re-write the panel to re-use widgets instead of having the actual widgets we need on it. (i.e. when widgets go off-screen we manually reposition them and re-set their data/layout, giving the illusion of a long scrolling list)

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #5 on: October 22, 2013, 02:54:00 PM »
It might be something that triggers when the momentum runs, which is only when you've released, but it isn't still yet. Internally on my team, we've made a cyclical wrapper for scroll lists and it increases performance quite a bit and also has the added bonus of having infinite elements in the list.

This is not something we're ready to release yet though, if we ever will be. If we get to a point where the higherups have no objections to it and we feel comfortable putting it out there, we'll post it in here or something.

kurozael

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #6 on: October 22, 2013, 04:07:11 PM »
I, too, have noticed bad performance after switching to NGUI 3.

NaxIonz

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #7 on: October 22, 2013, 06:20:38 PM »
It might be something that triggers when the momentum runs, which is only when you've released, but it isn't still yet. Internally on my team, we've made a cyclical wrapper for scroll lists and it increases performance quite a bit and also has the added bonus of having infinite elements in the list.

This is not something we're ready to release yet though, if we ever will be. If we get to a point where the higherups have no objections to it and we feel comfortable putting it out there, we'll post it in here or something.

Yeah, I've done infinite lists twice before in NGUI. Sadly, I no longer have access to the code :'(
Guess I get the fun of writing it again ^_^

NaxIonz

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #8 on: October 24, 2013, 09:09:03 AM »
In testing this morning, even when we reduce the pages of widgets from 8 pages down to 3 (the minimum viable amount to implement infinite scrolling) there is still a noticeable hitch on release after dragging. This is even on a Note 2 device, which is pretty decent. When we compare it to our build that used NGUI 2.6.4, the dragging is very smooth with 7 pages of widgets. And in case you wondering, the widgets have the same complexity as they did before. No new sprites, text, gameObjects, particles, or any UIWidget of any sort has been added to them.

NaxIonz

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #9 on: October 24, 2013, 09:58:03 AM »
More digging and I found why there was the lag spike.
It was coming from all the draw calls being destroyed. And they were being destroyed because the UIPanel was being set to dirty, which was causing a full rebuild. The UIPanel was being set dirty because we had page indicators at the bottom of the screen that were turning on/off based on the page you were on. (Basically gameObjects with 3-4 sprites on them, and they look one way or the other based on which page # you are viewing).

So, setting gameObjects active/inactive is bad-bad-bad in NGUI 3.0.x, at least it seems that way.

I'm not sure why the reasoning behind RemoveFromPanel() in OnDisable() of a UIWidget. If I might just turn it back on later, why make the widget go through all the effort of figuring out which panel it is on?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #10 on: October 24, 2013, 09:43:49 PM »
If the widget in the middle of the draw process gets removed or inserted, this causes the whole list to require re-batching, which is a slow process. Reason for that is this: if you had 3 widgets, one using atlas A, another using atlas B, and last one using atlas A, disabling the 2nd widget will allow the first and last widget to get batched into a single draw call.

blechowski

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #11 on: October 25, 2013, 01:24:49 AM »
This is bad.

I rather have constant, but small performance drop than a short, but big performance hit.

It would be great if we got some control over what happens when widget is disabled or enabled.
The typical usecase is that I disable a widget and then enable it some time later. It would be great if the widget did not cause the re-batching nor geometry rebuilding.
I would expect the re-batching to happen whe I destroyed the widget or the widget was no longer a child of the Panel.

Another typical use case is changing of sprite on a widget from the same atlas without the need to rebuild geometry. As we all know the more we do preprocessing in the editor the less processing is needed when the game runs.

NaxIonz

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 70
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #12 on: October 25, 2013, 01:13:18 PM »
If the widget in the middle of the draw process gets removed or inserted, this causes the whole list to require re-batching, which is a slow process. Reason for that is this: if you had 3 widgets, one using atlas A, another using atlas B, and last one using atlas A, disabling the 2nd widget will allow the first and last widget to get batched into a single draw call.

Seems a little assumptive that draw calls are more important than latency. It also assumes that you have more than one atlas in the project/scene. Since our scene has just one atlas, we pay this price of rebuilding but gain no draw calls. I can write wrapper logic around this (in our team's local code) to prevent it, but I have a feeling we're not the only ones that are in this sort of scenario. We only have 4-7 UI draw calls at any given moment, so that stutter from rebuilding is significantly noticeable.

blechowski

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #13 on: October 28, 2013, 04:22:47 AM »
@ArenMook
Are there any plans to resolve this issue? Or should we try on our own?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Serious performance spikes with 3.0.2 and UIPanel.LateUpdate
« Reply #14 on: October 29, 2013, 01:34:01 AM »
In the near future? No plans. I address such things as I encounter them. I work based on priority, not urgency. For example: exceptions thrown when a label ends in [-] is a high priority task. Eliminating rare spikes when you enable / disable content is a very low priority task.