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

Terrible Performance while Mouse Down

Discussion in 'UGUI & TextMesh Pro' started by phr00t, Jun 27, 2016.

  1. phr00t

    phr00t

    Joined:
    Apr 19, 2016
    Posts:
    41
    I'm seeing a large spike in CPU when I hold the mouse button down. It causes rendering & overhead time to increase, even though the scene's rendering complexity hasn't changed. I presume something funny is happening with the mouse raycasting, but I don't know what:



    Unity Beta 5.4b22 x64, DirectX 11, Windows 10 x64. CPU spike happens when the mouse is down, and immediately clears when the mouse button returns.

    I'm relatively new to Unity, so I'm not sure if there is a common pitfall that causes this behavior? Maybe this isn't happening on a full build? Any way to run a performance profile on a full build?
     
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    if unityUI is like my kissUI, when you want to Drag the Image, and the Mouse Leaves the Current Images area, and the Mouse Enters another images area... and in your own code, you move the image to follow the mouse cursor... it becomes a vicious cycle of Mouse Enter and Mouse Leave... So many GetComponent() calls. :/

    well, I added caching of images, or am about to, of the last few images the raycast hit, just to avoid calling GetComponent if possible. ;)
    well, kissUI does have another way to avoid this, an option to Ignore raycasting other images when a specific image is Dragged. Speed! :D

    webGL example of performance (Microsoft EDGE is fastest browser, then Chrome [when it doesn't get the Hiccups], then Firefox for me):
    http://kissui.izzysoft.com/support/index.php?action=demos;sa=dragdrop501
     
    Last edited: Jun 28, 2016
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Yea this is slightly expected as there is a lot of processing that is needing to happen to track what the mouse is currently hitting. if you feel it is a really large issue feel free to submit a bug and we can look into it further.
     
  4. phr00t

    phr00t

    Joined:
    Apr 19, 2016
    Posts:
    41
    Case 809888.

    This is a really large issue. Imagine trying to hit 90FPS+ for Virtual Reality & the biggest problem holding you back is holding down the mouse button.

    I opened up a completely blank, new project & saw large drops in performance with nothing but holding down the mouse. Something is going on wrong here. I trust you can find a solution!
     
  5. phr00t

    phr00t

    Joined:
    Apr 19, 2016
    Posts:
    41
    I'm glad to report I got a notification that this bug was fixed. I'll be looking forward to the next release to test!
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    BTW why are there 11 EventSystem updates going on in a single frame ?