Insane EventSystem.Update lag spike, no graphic raycasters in scene

Hello!

I have this action: On screen touch: Activate a UI gameobject with text and NO graphic raycaster, deactivate a gameobject WITH graphic raycaster. That’s it, however I’m still getting INSANE lag spikes for eventsystem, and I have no idea why.

Here’s the profiler:

It could be a lot of things, the most common is to have a lot of UI elements in the scene to the Event System have to check for all the UI elements.

For more informaiton please check here, it could help.

Have a look here:

https://forum.unity.com/threads/event-system-performance-pretty-bad.292570/#post-4109506

Basically you have 49.3% shown as “Self”, which is not much use. Use “Deep Profile” option, so it records a deeper callstack.

In my case, it was a call to DateTime.Now somewhere deep in the methods that was slow!
take a look at this:

I replaced the code with Time.time and it’s fixed now.