- Home /
iOS - touchesMoved called at irregular intervals
I'm making a game for iOS where you mostly drag big objects across the screen. When I run the game on an actual iPad/iPhone for a while (continuously dragging the object in circles across the screen) every 5 minutes or so the dragged object goes all stuttery for about 10-30 seconds. Then, it goes back to moving silky-smooth.
Visually, it looks like the game's frame rate dropped to 15 fps for a while, but in actual fact it's running at rock-solid 60 fps all the time. However, I noticed that the only thing that doesn't move smoothly is the dragged object, while the rest of the game is all running perfectly smooth.
This led me to believe that the stuttering is related to the touch input in iOS. So I started looking at touchesMoved, and saw that it's normally called every 16 milliseconds (so touch input runs at 60 fps). So far so good.
Then I noticed that when the object starts stuttering, touchesMoved starts being called at weird time intervals, fluctuating wildly between 8 milliseconds and 50 milliseconds.
So while the touchscreen is in this weird state, sometimes touchesMoved will get called just 8 milliseconds after the previous call, and sometimes it won't get called until 50 ms after the previous call. Of course, this makes the dragged object look all choppy because its position is updated at irregular intervals.
Do you have any idea what could be causing touchesMoved to stop being called at regular intervals, as it normally does?
Bonus:
-Whenever I tilt the screen to force the screen orientation to change, roughly 70% of the time the touchscreen goes into the aforementioned state where touchesMoved starts being called irregularly. Then after 10-20 seconds it goes back to normal and everything looks smooth again .
-I've tried this on two iPads and two iPhones, with iOS 6 and 7, and the issue appears in all of these devices.
-I've found several non-unity games where the same issue appears (you can try in the title screen of sword & sworcery, drag your screen across the screen in circles, tilting the screen from portrait to landscape occasionally, and you'll see how the dark cursor which follows your finger stutters for a while sometimes).
-Note I'm measuring the timings in objective-c using CFAbsoluteTimeGetCurrent, completely outside unity.
Your answer
Follow this Question
Related Questions
Check if mopub banner ad is on screen 0 Answers
How would I add OS X menu bar functions to a Unity app? 3 Answers
"Cannot use '@try' with Objective-C exceptions disabled" Error 1 Answer
Unity for iOS: UnityPause(BOOL) 0 Answers
Do you still need to know xcode or objective c to publish to iOS? 1 Answer