Author Topic: UIDraggablePanel SLOW with a lots of elements  (Read 4648 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
UIDraggablePanel SLOW with a lots of elements
« on: August 14, 2012, 08:23:55 AM »
Hello!

I have a HUGE problem with UIDraggablePanel. We're making a freemium game deeply integrated with Facebook. That mean we want to display at one moment the list of your FB friends, so you can invite them to play the game.

In order to do that, I have a UITable, that I fill with x rows, each row is just a prefab that contains 2 sprites, 2 labels, an image button (with a sprite on it), and a UITexture.
And... I have a list of 220 friends, so that means it create 220 prefabs.

When I start scrolling, well it's laggy as hell, like I have to wait 2-4 seconds to see the screen update...

Maybe i've done something wrong ?
I've noticed in the editor, that when you scroll, you just enable every geometry to display. But since they are not shown to the camera, it should not be render right (so no time consumed) ?

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #1 on: August 14, 2012, 08:40:17 AM »
After tracking things down in the Profiler, here what I have.

Even when I'm not moving or touching anything, there is a LOT of time (at least 99% of the time) spent in 2 methods :
UIPanel.LateUpdate() 50ms - and UIWiget.Update() 35ms

PhilipC

  • Guest
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #2 on: August 14, 2012, 10:39:40 AM »
From personal experience i would recommend not loading all the friends at once. Some people can have thousands of friends and if all loaded at once can use alot of memory.

As for what the issue is i'm not sure. Not alot is done inside UIWidget.Update so there is no reason it should be taking that long. Could it be more a issue with the device swapping the textures in and out of memory? (i'm assuming the UITexture is the avatar for each friend).

JRoch

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 140
    • View Profile
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #3 on: August 14, 2012, 10:48:29 AM »
Also, are you making one network call to resolve all of those friend lookups?  Are you doing that as part of the main Update loop?  (Perhaps this should be spawned off as a worker thread, so you don't have network connectivity stalling out render threads?)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #4 on: August 14, 2012, 11:10:58 AM »
From personal experience i would recommend not loading all the friends at once. Some people can have thousands of friends and if all loaded at once can use alot of memory.

As for what the issue is i'm not sure. Not alot is done inside UIWidget.Update so there is no reason it should be taking that long. Could it be more a issue with the device swapping the textures in and out of memory? (i'm assuming the UITexture is the avatar for each friend).

Yes but we have to at least load 50-100 friends, or the user will get bored to press the "next" button.
Yes the UITexture is the avatar of each friend, so what should I do there ? Create an atlas with all the avatar ?

Also, are you making one network call to resolve all of those friend lookups?  Are you doing that as part of the main Update loop?  (Perhaps this should be spawned off as a worker thread, so you don't have network connectivity stalling out render threads?)

Yes I'm making a network call, but it's done only one and definitely not in an Update loop (it's done via a couroutine) and after the end of this coroutine, I create everything.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #5 on: August 14, 2012, 11:52:00 AM »
When scrolling I have 15.000 triangles and 30.000 vertices and it's still laggy as hell even without using the UITexture...

UIPanel.LateUpdate() still taking 100ms! That's 0.1sc each frame...

PhilipC

  • Guest
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #6 on: August 14, 2012, 12:39:51 PM »
Yes but we have to at least load 50-100 friends, or the user will get bored to press the "next" button.
Yes the UITexture is the avatar of each friend, so what should I do there ? Create an atlas with all the avatar ?

Yea i agree that having at least 50 friends it a good idea i was just saying that 220 seemed way to high.

It might not be a bad idea to create a atlast with the avatars. From what i remember the smallest texture you can get from FB is the 50 by 50 square image (which will be turned into a 64 by 64 on mobile devices as they like POT) which will require 16KB of memory for each texture (it doesnt seem like alot but can add up quickly). UITexture will now allow you to specify where on the texture the UV's are so you can set up that functionality yourself.

How complex of a menu do you have? i'm just curious before i go looking at LateUpdate.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #7 on: August 14, 2012, 12:47:22 PM »
Hehe, thanks for the answer,

Maybe I'll try to implement the atlas, but I'm not sure I'll do it because I have a lot of other things to do for the game.

Can I send you a screenshot of the interface via email (we don't want to leak things on the internet right now...) ?

PhilipC

  • Guest
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #8 on: August 14, 2012, 01:41:09 PM »
Got the screen shot we will keep this going in email till we have a solution to post.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: UIDraggablePanel SLOW with a lots of elements
« Reply #9 on: August 14, 2012, 01:41:58 PM »
Nice ! Thanks