Author Topic: Lag in Scrollview Drag  (Read 2839 times)

sb_007

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Lag in Scrollview Drag
« on: November 22, 2017, 06:38:33 AM »
When scrollview has , say, 50+ items, the drag gets dead slow on device & editor. But using "mouse scroll button" in editor, its as quick as bullet (which is fine).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Lag in Scrollview Drag
« Reply #1 on: November 23, 2017, 01:31:50 AM »
I can only suggest making good use of the Profiler to find the culprit. I certainly see no issues with this on my end, and I've had some long scroll views.

sb_007

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Lag in Scrollview Drag
« Reply #2 on: November 23, 2017, 02:18:04 AM »
I can only suggest making good use of the Profiler to find the culprit. I certainly see no issues with this on my end, and I've had some long scroll views.

I'm having 10 labels & 5 sprites on each element of scroll view. Labels have outline value of 1 & few sprites have gradient too.
Anything you could suggest for better performance.

sb_007

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Lag in Scrollview Drag
« Reply #3 on: November 23, 2017, 03:56:02 AM »
UIRect.Start() and UIRect.Update() shows 1500+ "Calls" in Profiler.
Fonts.CacheFontForText shows 5000 calls in Profiler.

Note: I have 4-5 anchored elements in the current screen. Having drawn once, the anchoring is Reset by me. Batches increase by 15 when this screen is SetActive.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Lag in Scrollview Drag
« Reply #4 on: November 29, 2017, 08:19:19 AM »
Anchoring sounds like your problem. That, and dynamic fonts. CacheFontForText is not an NGUI function, so I assume it's something to do with Unity's dynamic font system. Your anchoring causes things to move, which causes draw buffers to be marked as changed, which in turn causes draw calls to be re-created, which leads to rebuilding all of your text. There in lies your slow-down.