Author Topic: Scrollview makes FPS drop  (Read 5663 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Scrollview makes FPS drop
« on: January 23, 2014, 12:54:26 PM »
Hey there.

Using the latest NGUI Version.

So I have a ScrollView (set to Alpha Clip, I read that's faster than Soft Clip, so I used this instead) with a Childobject: A UIGrid.
This UIGrid holds Labels like this:



So when I fill this grid with Labels on my mobile device (iPhone 4) at first the framerate is fine, but when I fill the ScrollView/Grid with a lot of Labels (let's say around 40++) the FPS drops to 30fps, when I get more then it drops again.
The fun thing is, as long as I don't scroll with my fingers, the FPS stays at 50~FPS, as soon as the finger touches the display and moves the View the fps drops.

Is there a way to prevent that? Did I miss something in the settings?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview makes FPS drop
« Reply #1 on: January 24, 2014, 08:48:29 AM »
When the scroll operation begins, all widgets are bundled into one draw call whether they are visible or not. When the scroll view is stopped, the culled widgets disappear. There is an option for this (cull while dragging) on the panel. Check to see if you get better performance with it on or off.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Scrollview makes FPS drop
« Reply #2 on: January 24, 2014, 09:10:26 AM »
Ah yes, I already tried that yesterday and it is a little bit better, but still, the more Items the Grid has, the lower the framerate gets when the view is dragged/scrolled.

Why does that hit the perfomance at all, when all the widgets are bundled into one DrawCall?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview makes FPS drop
« Reply #3 on: January 24, 2014, 09:20:58 AM »
When things are moving, additional checks need to be made, and depending on what you're doing, draw calls may need to change too. I suggest profiling it.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Scrollview makes FPS drop
« Reply #4 on: January 24, 2014, 09:24:11 AM »
Hm, I don't have Unity Pro.

But I found this topic here: http://www.tasharen.com/forum/index.php?topic=7348.msg34657#msg34657

Would "Plan A" be the solution I'm looking for? If so, how exactly can I recycle the items?

Edit:

In another topic you stated this:

Quote
Culling on panels does not improve performance. It forces the panel to re-evaluate what's visible every singe update, and then re-create draw buffers, which is very slow. It's better to leave it off so that the panel does not do any evaluation, and the draw buffers don't change as you drag the content around.

So why did you suggest it? Does the "Cull"-Setting in the latest version of NGUI make the performance better, indeed?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview makes FPS drop
« Reply #5 on: January 24, 2014, 09:31:24 AM »
I suggested you to try it to see if it would in your case. For recycling items, if you have 6 labels and only 4 are visible, as you scroll and one moves far away, move it to the opposite side. It's custom functionality.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Scrollview makes FPS drop
« Reply #6 on: January 24, 2014, 09:34:22 AM »
Ah I see.

So beside this "solution" there is nothing I can do?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview makes FPS drop
« Reply #7 on: January 24, 2014, 10:25:26 AM »
Nothing I can think of off the top of my head. Other than upgrading to Unity Pro, that is.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Scrollview makes FPS drop
« Reply #8 on: January 24, 2014, 10:36:37 AM »
I see, mhm.

Would it make sense to try something like this:

- I save the reference to the Labels in a seperate Array
- only 5 labels are displayed at a time (for example)
- when the Scrollview is dragged, the label which goes offscreen gets removed from the grid completely, but only temporarily
- when I drag it back, I get the reference and add it back to the grid to it's former position

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview makes FPS drop
« Reply #9 on: January 24, 2014, 10:43:09 AM »
If you're just displaying a list of labels, look at the UITextList (check the chat box example). It's able to display lines of text and lets you scroll through them without having to create all those extra labels.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: Scrollview makes FPS drop
« Reply #10 on: January 24, 2014, 10:47:37 AM »
It's not simple text but also "Buttons", all these Labels have colliders and when any of them is clicked all labels fade out, a PageFlip-Animation is played, and the clicked "Quest" appears (UISprite and other UILabels).
If this still is possible to manage with UITextList AND will give me a better perfomance I'll check it out.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview makes FPS drop
« Reply #11 on: January 25, 2014, 02:39:14 AM »
No, the text list is just for simple labels.