2

My team and I ran into a bug, which is probably caused by the iOS system time not incrementing monotonically, but jumping backwards. The measured time difference was about -50 milliseconds. (That's obviously no leap second or time zone issue.)

We understand that iOS devices synchronize their time with NTP servers while being online. But the negative time difference was observed while having no network connection at all.

Are there any reasons iOS would update the system time while offline?

We'll certainly need to follow this approach for measuring elapsed times. But nevertheless, we'd like to understand what was causing the jump.

Update: After 2 hours in airplane mode we observed a time jump of 637 ms into the past with System.DateTime.Now on a iPad Mini 2, while CACurrentMediaTime kept increasing monotonically. It's still unclear why iOS should do such a significant jump after such a long time without NTP updates.

Falko
  • 17,076
  • 13
  • 60
  • 105
  • was the device connected to a computer ? I've read some issues regarding time sync when connected – GIJOW Aug 03 '17 at 20:19
  • @GIJOW: That is interesting! As far as I know it was charging, but not connected to a computer. – Falko Aug 03 '17 at 20:28
  • Just charging on outlet should not interfere. At least in a normal world. – GIJOW Aug 03 '17 at 20:31
  • Can you please either modify your question such that it is [on topic for Stack Overflow](https://stackoverflow.com/help/on-topic), or post it at a more relevant Stack Exchange site, such as [SuperUser](https://superuser.com/) or [Ask Different](https://apple.stackexchange.com/) or [Electrical Engineering](https://electronics.stackexchange.com/)? – Matt Johnson-Pint Aug 03 '17 at 22:18
  • Also note that all clocks are subject to [drift](https://en.wikipedia.org/wiki/Clock_drift), and most modern operating systems employ drift correction algorithms. You may want to ask about specific types of drift correction employed on iOS, though that would be a question for one of those other sites. ;) – Matt Johnson-Pint Aug 03 '17 at 22:21
  • @MattJohnson: I asked on SO, because I've found many other discussions about different sources of time on iOS and their suitability for measuring elapsed times. [This answer](https://stackoverflow.com/a/30363702/3419103) mentions reasons for such time jumps, but none of them seems to apply in my case. [This answer](https://stackoverflow.com/a/13741793/3419103) mentions *significant time changes*. But what are insignificant changes? I'm aware of clock drifts. But this is more about a piece of documentation I haven't found, yet. Ok, maybe Ask Different is another good place to ask... – Falko Aug 04 '17 at 03:54

0 Answers0