Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can the scrollrect performance issue even be fixed?

Discussion in 'UGUI & TextMesh Pro' started by techmage, Feb 10, 2015.

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    So the issue is well known, some Unity devs have stated the performance is a priority. But I am really wondering, can it even be fixed?

    If I understand it correctly, using the scroll rects basically causes a regeneration of the UI mesh every tick it scrolls. If that is the case it seems that the scroll rect can never actually become radically preformant. Perhaps some percentage improved with more optimized algorithms, but never perfect. If this is the case then it seems to have a very performant, complex, scroll rect, we must do the multi-canvas trick.

    So I am wondering, is something like the multi-canvas trick part of Unity's intended solution to this? Or should I just start rolling my own right now?
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    multi canvas is just a overall performance trick. The scroll rects though are a different matter and i'm pretty sure the issue is partly on the cpp side.
     
  3. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    After going multicanvas (+ no pixel perfect on nested one), and disable all UI layouting related components after rect content is layouted (canvas size fitter, layout groups, layout element) we were able to improve performance of one of our complex lists from ~2fps to ~30fps on lumia 630. Hope this helps.
     
    doggan and JohnTube like this.
  4. SmartyP

    SmartyP

    Joined:
    Nov 15, 2012
    Posts:
    7
    I just wanted to say thanks to Raimis for the notes on performance boosts. I tried disabling the layout group on my panel after populating it and got some minor improvements. I also tried setting items in my list off-screen as inactive, which did a little bit as well, but the massive improvement was turning off pixel perfect for the canvas - the frame rate difference on Windows Phone was huge disabling that (which I guess seems somewhat obvious now). I ended up using 3 different canvases and putting my lists in the one without pixel perfect on to get a great boost in FPS. Thanks much for the tips!
     
  5. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    That's ok :) we are all here for the answers and sometimes we do get them. Glad I could've helped.
     
  6. Skflowne

    Skflowne

    Joined:
    Apr 6, 2014
    Posts:
    14
    Hi, could you explain or point me to some resources explaining the multi canvas technique ?

    I need to make a scroll list made up of other lists that all need to have a vertical layout group, plus I use the layout groups everywhere just to make sure things are presented well.

    Everything runs fine in editor, but on the devices, iPhone 6 even has small lags and iPad 3 has very perceptible lags when scrolling.
     
  7. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    I don't know any written resources. Simply place lists on other canvas than all other UI elements and disable pixel snapping for that canvas. After screen is initialized you can also disable all autolayout components, this was also mentioned above.
     
  8. Skflowne

    Skflowne

    Joined:
    Apr 6, 2014
    Posts:
    14
    Do you mean Pixel Perfect check box by pixel snapping ? I already deactivated this.

    It seems by deactivating other menus not in use with SetActive and removing some of the layout components, I've been able to get better performance but still not so great on iPad.

    The strange thing is on Android (tested on Sony Xperia Ray S18i and Samsung Galaxy Pocket GT-S5310) don't lag so hard even though they are less powerful. Of course they also have a much smaller resolution.

    On iPhone 5S it's now flawless.

    Also I removed some content size fitters that were children of layout components.

    I will now be trying to use the multiple canvas technique instead of SetActive, but as far as I've tried, it seems like the sorting layers in the canvas are different from what's on the camera. I'm not sure how I'm supposed to set this up.
     
  9. Alexander-M

    Alexander-M

    Joined:
    Oct 21, 2013
    Posts:
    8
    Can anybody explain me how to make before-mentioned mulitcanvas trick right? I think I got it working in Unity 4.6, but now I'm using Unity 5.3 and I don't see any performance difference. What I do: ScrollRect's content has it's own canvas, content is one UI Text (TextMeshProGUI to be precise), content's SizeContentFitter is disabled. Still see spikes in profiler when I scroll my text.
     
  10. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    First make sure Pixel perfect is disabled as it will result in significant performance impact.

    Make sure you don't have any layout components constantly re-adjusting stuff while your scroll.

    Lastly, checking in the Profiler (deep profile) you should be able to see what components are causing these spikes when you scroll. When looking at Canvas.SendWillRenderCanvases(), you should not be seeing any layout calculations related calls or from the TextMeshPro component. If you are then you have some layout component or scripts that could causing this extra processing.
     
  11. Alexander-M

    Alexander-M

    Joined:
    Oct 21, 2013
    Posts:
    8
    Thanks for the response, Stephan. Pixel perfect is of course disabled, and as I wrote ContentSizeFitter is disabled after calculations. Profiling shows that Android lags are caused by rebuilding UI batch: PutGeometryJobFence and Canvas.BuildBatch. That's what I want to eliminate by applying multicanvas trick. I just can't find some tutorial about how to do it right.
     
  12. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    [Canvas Main UI]
    [Canvas ScrollRect1]
    [Canvas ScrollRect2]

    This is how your game objects should look in hierarchy. So when something happens with the ScrollRect1 it only rebuilds the content within [Canvas ScrollRect1]. if you have all your UI within single canvas, when scroll rect is moved it will do exactly what you experience, rebuild every single element every frame just because of scroll rect.
     
  13. Stephan-B

    Stephan-B

    Unity Technologies

    Joined:
    Feb 23, 2011
    Posts:
    2,269
    This is similar to grouping static objects into a single canvas and grouping non-static objects that will move into their own canvas. Makes sense. As Unity will only have to rebuilt a single element as opposed to an entire canvas filled with potentially 30 elements.
     
  14. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    @phil-Unity is somebody working on the scrollrect cpp problem?

    I'm soon done with my app, which consists almost of scrollrects.
    would be sweet if it could stay at 60fps when scrolling.

    Unity UI is amazing despite the performance issues with the scrolling.
    If someday we could be able to disable the gameloop and use UI only there s no need for xamarin anymore :))
     
    Last edited: Mar 20, 2016
  15. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    756
  16. MV10

    MV10

    Joined:
    Nov 6, 2015
    Posts:
    1,889
    "Move" in the sense of actually changing the rect coords, or including the sense of animations, such as button presses? What about changes in visibility?
     
  17. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
  18. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    Wow, wish I decided to export this as asset store package when I was working on it during Unity 5 betas :( Had the same script done myself about 1 year ago :)
     
  19. mogwhy

    mogwhy

    Joined:
    Nov 20, 2014
    Posts:
    36
    @Raimis: cool. how is your framerate? scrolling nice?
     
  20. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    It improved a lot compared to scrollrect, but we found out that the whole UI mechanism just hates moving parts. If i had to do it now, i guess i'd try to mix ngui with unity gui and that would give the best results.
     
  21. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Slows Down?
    Do you mean when you have multiple Window panels?

    Ex: http://kissui.izzysoft.com/Examples/DragDrop501.html (unity's WebPlayer)
     
  22. Raimis

    Raimis

    Joined:
    Aug 27, 2014
    Posts:
    160
    I havent used this UI in a while and things might have changed, but back then it used to be that if there's a change in canvas - the whole canvas gets redrawn/recalculated. So having a moving element is essentially slow with this new ui. Once again, I haven't used this UI since ~August, so things might have changed.
     
  23. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    756
    EDIT 27.08.2016: Hey guys, happy to announce V2.0 is out, improved and with horizontal scrolling support: http://u3d.as/xXQ

    Original message:
    Yeah, only vertical scrolling is supported, though there may be some very creative ways to simulate a horizontal scrolling from the vertical one, but we were dumb and didn't find one in a reasonable amount of time :D. If someone finds a way (the easy way, I mean) for faking a horizontal scroll, I'd like to know, so I can update the docs.
    Of course, if we'll receive a few more requests for horizontal scrolling, we'll integrate it - the hard way.
     
    Last edited: Aug 27, 2016
  24. Bilelmnasser

    Bilelmnasser

    Joined:
    May 16, 2014
    Posts:
    18
    Canvas.pixelPerfect
    Force elements in the canvas to be aligned with pixels. Only applies with renderMode is Screen Space.

    Enabling pixelPerfect can make elements appear sharper and prevent blurriness. However, if many elements are scaled or rotated, or use subtle animated position or scaling, it may be advantageous to disable pixelPerfect, since the movement will be smoother without.