Search Unity

Bug UIToolkit Severe Lag when moving mouse

Discussion in 'UI Toolkit' started by craftsmanbeck, May 5, 2021.

  1. craftsmanbeck

    craftsmanbeck

    Joined:
    Nov 20, 2010
    Posts:
    40
    Since updating to Unity 2021, in my project I've experienced severe frame drops (from 300FPS to 15) both in-editor and in-build when moving the mouse over an active UI Document. Using deep profiling, the cause seems to be VisualTreeStyleUpdater.TraverseRecursive, called from within the Update Style marker. Here's the kicker though, the lag completely disappears if the UI Builder window is open.
    Any ideas if there's anything I can do to prevent this, or work-around it for builds?

    Update: I was able to work around the issue by disabling the mouse-following visual element I had. In previous UIT/Unity versions it seems like it would only trigger updates when relevant visual elements were changed, now it seems like if anything changes everything gets updated.
     
    Last edited: May 8, 2021