Lag spike from SystemEvent with the first touch.

Hey there.

I’m using Unity 4.6.6 for Android and iOS. I have a Physics Raycaster and Graphics Raycaster on my scene and implemented IDragHandler on multiple objects. There is at most a dozen of those objects, not more.

On low end devices, each time I try a drag for the first time, a lag spike occur. This lag spike would be without importance if it wouldn’t make my collision skip multiple frames, thus having the object I drag jump over each other instead of properly colliding. :frowning:

Does someone have a hack of some sort or know the reason of this behaviour?

I saw multiple post on the forums without any real answers.

Bump! This really is problematic for me.

have you tried using the profiler to determine what is causing the problem specifically? without knowing what you’ve actually done it might be a bit hard to guess the issue.

In 4.6.1 I saw lag spikes on touch on Android devices. Did not debug beyond that. Do remember that it was worse on first touch but also happened ~10 minutes into gameplay. The lag was coordinated with touch.

The profile don’t indicate more than just EventSystem.Update() call. The rest is invisible.

Bumping back this, because we still don’t know why it does it and how to fix it. :frowning:

Bump again, I don’t know what to do with this. I don’t want to rewrite all my input management scripts as we are close to the release. :frowning:

When you say low end devices how low are we talking? Like is for some reason using the physics raycaster and it creating/ shooting the ray causing the issue?

I can’t say if it comes from the raycasting itself. The effect occur only the first I start a swipe gesture, freezing the screen for a good half second, then it stays clear for the entire lifetime of the app. It feels more like the system have to initialize something on the first raycast event.

The devices I used to test it are :

  • HUAWEI P6-U06, under android 4.4.2 (quite visible)
  • Samsung Galaxy S4 Mini
  • iPhone 4 (less visible)

Are you for some reason updating the list of objects where you are dragging from by deleting them and creating it back again?

If that is the case it is most definitely the issue, I had the same problem since I was using a sorted item list and every time I needed to drag out or drop an item I had to sort again. Deleting the entire item collection and creating it back was a heavy operation for the mobile device I was testing, it created a spike in the Garbage Collector (I was using Unity 5.1.2f3) and was making a huge lag when dragging an item out, you didn’t even receive feedback for a couple of seconds, I was using a dozen objects exactly.

My solution was to parent the GameObjects to a disabled CacheTransform and then search the objects in the cache first when filling the list again instead of trying to create them. If you have way too many objects I would recommend to use a coroutine that handle this over several frames, like setting a threshold amount of objects per frame, but for my case it was not necessary.

Let me know if this was your issue.
Best regards,
Lermy

I only use the events to move the game objects around the world. Of course using rigidbody. If it was what you though, it would freeze not only the first time but each time I move them.

Hmm i’m not sure and i’m not really seeing much of a spike on my side. I dont have any devices that low to test it on

Can you poke the EventSystem by calling it’s various methods to get it to initialise earlier while loading?

Proceed with caution, that sort of behaviour really is a hack.

Confirmed, I found this one yesterday. Was wondering why i get frame drops ( 100-200ms lags ) on Android only.
And my phone is not the low end, Samsung Note 4. Looks like it is definitely to do something with the EventSystem. haven’t checked the source code for it for possible reason but this is really annoying.
Even the simplest scene, clean, make a button, make o rotating 3d box on the screen so you can see the lag when you click the screen the first time. After the first click the consequent clicks wont stall. But after say 10 seconds, its back.
Probably due some garbage collection done so I fixed this by doing a script that touches the screen once per every second. Works now. Never lags anymore from the first click.

1 Like

We have the same issue. Can you post this script please?

1 Like

Auto generated EventSystem comes with StandaloneInputModule component. After removing it EventSystem no longer produces huge spike on first touch on mobile devices.

1 Like

Hi. I hav ethe same problem…but removing StandaloneInputModule component all button system stop to work. Someone fix this bug? I work in Unity 5.6.1f1.
Tnaks and sorry for my bad english.

Unfortunately I have this problem too :frowning: Any updates?

I have to bump this problem. It’s causing a noticeable first touch lag on my game too. Removing the StandaloneInputModule doesn’t work. Any help is appreciated.

same prob here…First touch = 500 ms lag…Android mi a1…