Author Topic: Huge performance drop after updatating from 2.7.0 to 3.7.5  (Read 19288 times)

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Huge performance drop after updatating from 2.7.0 to 3.7.5
« on: March 20, 2015, 08:40:50 PM »
Hello,
we have developed the interface of our game with NGUI 2.7.0. Now, in order to use the more advanced features of NGUI 3.x, we update it to 3.7.5.
After the update, I noticed a huge performance drop, in particular when dragging the vertical leaderboard (made with a draggable panel). It contains 50 entries, of which only 10 are visible.
The performance drop occurs especially when clicking on the draggable panel and releasing it.
In the attached images, you can see the profiler of the same draggable panel with NGUI 2.7.0 and NGUI 3.7.5 (in both cases we have used Unity 4.5.5).
With NGUI 3.7.5, even if the CG if a bit smaller, the time frame goes from 10ms to an impressive 37.7 ms.

Is there a way to fix this? I already tried to uncheck "static" the UIPanel but without success.
Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #1 on: March 22, 2015, 07:59:51 AM »
What's causing your GC allocation? NGUI should be causing no allocation at all while dragging panels if panel's culling is off.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #2 on: March 22, 2015, 11:50:41 AM »
Panel's cull check box is unchecked.
I have attached a deep profile. As you can see, there are 22440 (!) call to betterlist.add.
Anyway, the problem seems to lay on drawcall functions, cause they allocate the most of the time in the frame.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #3 on: March 23, 2015, 09:39:58 AM »
Right, that's just draw call creation. My question is what's causing the draw calls to be changed? While dragging with culling turned off, the entire draw call does not change at all. It only changes at the time you start dragging. Do you have some element that's constantly changing, causing draw calls to be re-created?

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #4 on: March 24, 2015, 01:49:07 PM »
Quote
Right, that's just draw call creation. My question is what's causing the draw calls to be changed? While dragging with culling turned off, the entire draw call does not change at all. It only changes at the time you start dragging. Do you have some element that's constantly changing, causing draw calls to be re-created?
No, the panel is loaded and then it doens't change. Anyway, i included the deep profile of the same panel with NGUI 2.7.0 to make a comparison.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #5 on: March 25, 2015, 11:53:57 AM »
Amy ideas? On a medium / low level device (LGP700) all the draggable panels are now almost unusable.
With NGUI 2.7.0 everything was much smoother.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #6 on: March 25, 2015, 12:20:07 PM »
The behaviour of scrolling hasn't changed since 2.7, so it's something else. As I said, figure out what's causing the draw calls to be rebuilt and you will have your answer.

Add a Debug.Log to UIPanel.UpdateWidgets(), around line 1600.
  1.                                 // First update the widget's transform
  2.                                 if (w.UpdateTransform(frame) || mResized)
  3.                                 {
  4.                                         // Only proceed to checking the widget's visibility if it actually moved
  5.                                         bool vis = forceVisible || (w.CalculateCumulativeAlpha(frame) > 0.001f);
  6.                                         w.UpdateVisibility(vis, forceVisible || ((clipped || w.hideIfOffScreen) ? IsVisible(w) : true));
  7.                                         Debug.Log("Transform changed: " + w.name, w);
  8.                                 }
  9.                                
  10.                                 // Update the widget's geometry if necessary
  11.                                 if (w.UpdateGeometry(frame))
  12.                                 {
  13.                                         changed = true;
  14.                                         Debug.Log("Geometry changed: " + w.name, w);
  15.  
  16.                                         if (!mRebuild)
  17.                                         {
  18.                                                 if (w.drawCall != null)
  19.                                                 {
  20.                                                         w.drawCall.isDirty = true;
  21.                                                 }
  22.                                                 else
  23.                                                 {
  24.                                                         // Find an existing draw call, if possible
  25.                                                         FindDrawCall(w);
  26.                                                 }
  27.                                         }
  28.                                 }
P.S. And make sure you're on the latest version of NGUI. You mentioned 3.7.5, which is quite old now.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #7 on: April 10, 2015, 07:39:05 PM »
Hello,
sorry for the late but i had to fix other issues in our project. I added the suggested Debug.Log in UIPanel, and it seems that all components of the leaderboard is causing the draw calls to be rebuilt during the drag (in the console there are 560 logs). See attached image as reference. I really dont know if this is normal or not. Please help.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #8 on: April 12, 2015, 08:22:06 AM »
Any ideas? We really need this to be sorted out.
Thanks.

yuewah

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 180
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #9 on: April 12, 2015, 09:35:35 AM »
Are you scaling, moving the individual widgets during dragging ?

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #10 on: April 12, 2015, 04:18:18 PM »
not at all. Its a simple draggable panel. The only distinctive trait is that entries are created runtime (cause leaderboard data is downloaded runtime from a server).
Anyway,everything is the same as the NGUI 2.7.0 version, which didint suffer of this issue.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #11 on: April 12, 2015, 04:46:21 PM »
I just did a simple test:
1. New scene, ALT+SHIFT+S, ALT+SHIFT+C, right-click, add scroll view.
2. Drag & drop the sprite into the scroll view, right-click, attach drag scroll view.
3. Duplicated the sprite a few times, changed the names to make them unique.
4. Run, drag them around. I see the "Geometry changed: XXX" being called when items enter/exit the scroll view -- exactly what I expect as "culling" is on by default.
5. Changed "culling" to off, tried again -- nothing changes during the drag operation at all now.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #12 on: April 13, 2015, 04:55:32 AM »
Well this is weird.
I checked the panel and, as expected, cull is false. During dragging, huge amounts of geometry changed calls.
Set cull to true, much less geometry changed calls (only items that enter or exit the scroll view).
Definitely a 3.7.5 bug.
I'll try with latest NGUI version.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #13 on: April 13, 2015, 09:29:33 PM »
i just updated to the latest version on Asset Store (3.8.2) and the behaviour is the same:

if cull is false, during dragging there is huge amount of geometry changed calls.
If cull is true, much less geometry changed calls (only items that enter or exit the scroll view).

I really dont know what happening.
With cull set to true things seems much better anyway.

newlife

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: Huge performance drop after updatating from 2.7.0 to 3.7.5
« Reply #14 on: April 14, 2015, 01:20:21 PM »
I just did a simple test:
1. New scene, ALT+SHIFT+S, ALT+SHIFT+C, right-click, add scroll view.
2. Drag & drop the sprite into the scroll view, right-click, attach drag scroll view.
3. Duplicated the sprite a few times, changed the names to make them unique.
4. Run, drag them around. I see the "Geometry changed: XXX" being called when items enter/exit the scroll view -- exactly what I expect as "culling" is on by default.
5. Changed "culling" to off, tried again -- nothing changes during the drag operation at all now.

I made the same test with the included scroll view panel example and the results are the same when culliing is on, but when culling is off I see 148 logs call in the console.
Can you please check this?
Using NGUI 3.8.2 and Unity 4.5.5.

Anyway, performance of draggable panels are still far away from NGUI 2.7.0.