How to avoid GUI.Repaint spikes

I am getting GUI.Repaint->Event.Internal_MakeMasterEventCurrent() spikes (60 ms) when profiling on an android device on every 40th frame approximately.
I am not using OnGUI() method call in any of my scripts. Is there any way to totally remove the GUI.Repaint spikes.

Allegedly it’s not enough to disable the script containing th OnGUI call - you have to remove it. Perhaps that helps?

Now I have commented out all OnGUI methods. However It has not helped much. I am heavily using TextMesh with dynamic font. Could it be because of that ?

Is that a Deep profile?

Yes

I have similar issue while, general I don’t use Unity GUI, my interface entirely in NGUI, why do I have a spike in 36ms from GUI.Repaint → GUIUtility.EndGUI (). Is there any way to disable totally buggy and brake standard Unity GUI?

its (2018) and Still i face this problem

1 Like

Hi Guys,

I don’t have OnGUI() anywhere in my entire project but still get 384B GC Alloc. My Unity version is 2017.3.0f3, Please help me. The only thing I used are UI Text & UI Image, Please Help

Thanks & Regards,
Bhanu

I don’t have onGUI and still see GUI.Repaint spikes… I’m on 2019.1.8f, can someone explain how to reduce the cpu usage by GUI.Repaint?

Same here.

1 Like

Same here, 2019.3.0.

Same here.

90ms at constant spikes for about 10sec - happens about every 2-10min even if the Editor is not focused, I can watch youtube videos in a browser not paying attention to unity being open and I will still get the lag.
What exactly is happening here and how to avoid it? It seems to be the scene view, inspector view and hierarchy view.
I’ll make further test, closing all those editor tabs to see if the lag is still happening.

Did you solved it?

IMGUI is quite slow, so I still have some troubles getting a stable framerate when the inspector is open but the >10sec spikes were caused by my damaged graphics card.
I had to change the cooler because it was constantly overheating … idk why it only happend when Unity was open and not when playing games.
Upgrading to 2020.1 also was a big speedup, the scene view is just way faster now, as well as opening scripts in the inspector - everything feels more responsive than back then. If you face the same issue, check your GPU.

PS: Later I had a “delegate leak” in a custom debug drawing system I wrote, which was calling CustomDrawGizmo() and CustomDrawHandles() on all monobehaviours in the scene which also caused extreme lags. Basically I was drawing all Gizmos and Handles for all Objects in the Scene 100+ times per Editor Update Tick - but making the same mistake as I did is quite unlikely.
Fun Fact: I wrote the system to increase the performance because putting an if() condition into the OnDrawGizmos() Method can kill the performance when you have lots and lots of objects with potential gizmos to draw.

1 Like

Anyone found a solution for this nasty problem?

+1

the unity 2020 is bullsheet every time has opening has erorr for proxy collobrate or other package
asset store in package manager not work and again is bullsheet
old version is so better
. always has repaint all wtf …
i tired that unity version
unity 2018 is so better

In my case, Rewired was making a problem. I had OnGui turned on, it all works now.

Im getting this too on a really simple scene. If I click aroudn the ui and tunr things off and one randmly it suddenly goes away, but that is very annoying, any solution ?