Search Unity

[Unity 5] Very dangerous problem of uGUI which can make your game fps suddenly drop!

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by Katori Nori, Mar 6, 2015.

  1. Katori Nori

    Katori Nori

    Joined:
    Mar 3, 2015
    Posts:
    6
    Simply create a new scene, choose GameObject / UI / Button to create a button of uGUI.
    Then choose Windows / Profiler, turn on Record. On Overview window, click the title of column named 'GC Alloc' ( for sorting by GC Alloc )

    Play your scene.

    Look at the Overview window of profiler, you will see the first row named GameView.GetMainGameViewRenderRect() which alloc 32 Bytes every frames. But it appears only on the Editor, not on Players (like iOS, Android). Others alloc 0 Byte. So it's ok.

    But try to click the button. At the time you click, a row named BehaviourUpdate() appears and allocs 1.1KB. Then try to hold down the button, 1.1KB alloc every frames! On iOS, it is 160 Bytes every frames instead of 1.1KB.

    I wonder that if I hold down the button for a while, until the heap full, the 'Garbage Collector' may appears, clean heap, and drop the fps?

    Thank you.
     
    MrEsquire likes this.
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,462
    I think you're just seeing editor gc, which is normal and harmless.
     
  3. Katori Nori

    Katori Nori

    Joined:
    Mar 3, 2015
    Posts:
    6
    How can I see the real gc (iOS) ?
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,462
    Profile on device (see docs). You create a development build and build + run from unity with the auto attach profiler tickbox.

    Profiler adds a tiny overhead, but I kind of like that as I surf so close to the limits so its a tiny buffer ;)
     
  5. Katori Nori

    Katori Nori

    Joined:
    Mar 3, 2015
    Posts:
    6
    yes, I did the same. the result is 160 Bytes alloc every frames with my iPhone 6.
     
    MrEsquire likes this.
  6. Rusfighter

    Rusfighter

    Joined:
    Jan 18, 2014
    Posts:
    60
    Got a similar problem, however if you holding a button nothing gets allocated, but if you clicking the button a lot, a lot of allocation happens (could be laggy if you have controllers made with UI).

    Tested on android with the free profiler.
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,462
    Did you guys resolve this or report a bug?
     
  8. radokhlebov

    radokhlebov

    Joined:
    Mar 13, 2015
    Posts:
    14
    Have the same problem. Screenshot provided. Version: 5.3.5f1

    UPD: FOUND A TEMP SOLUTION: set button -> transition to none

    Strikes are gone! Color Tint causes this bug.
     

    Attached Files:

    Last edited: Jun 27, 2016
    ilmario and MrEsquire like this.
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,462
    Ah I remember that... yeah tinting caused GC for me too back when I used it.