react-native-background-timer icon indicating copy to clipboard operation
react-native-background-timer copied to clipboard

Interval time changes periodically

Open jonathan-golorry opened this issue 8 years ago • 6 comments

I'm testing this module by setting up a timer to log the time every 10 minutes and running it for extended periods. When I check the times logged, it is sometimes every 10 minutes, but sometimes switches to a new, longer interval. It is weirdly consistent when it switches, the new interval lasting potentially for hours and being stable to within 10 or so seconds. I've seen intervals around 14, 16, or even 21 minutes, so it isn't just a clean multiple of the original.

Has anyone else experienced this instability or know why it is?

jonathan-golorry avatar Nov 17 '16 08:11 jonathan-golorry

I've experienced it as well (on Android). Very odd when it occurs, as like you said, the times can vary greatly.

I'm guessing it's a limitation of the underlying timer/alarm/callback system used -- perhaps when cpu usage is too high or something, it slows down the timer triggerings. (though the variance seems extreme, if this is the explanation)

Venryx avatar Feb 19 '17 16:02 Venryx

I have the same issue. both ios and android,

perfecten avatar May 14 '17 12:05 perfecten

when running a long timeout you won't have clock drift accounted for.

looking at the project source at the time of this comment the interval function also doesn't account for clock drift.

see: http://www.ntp.org/ntpfaq/NTP-s-sw-clocks-quality.htm

gregl83 avatar Nov 17 '17 23:11 gregl83

In my case, when the android phone is on, everything works great, both in foreground and background. But when the phone is locked (screen off), the interval changes a lot, but still working. This difference is so long that a need to find out something to fix that.

netpedro-com avatar Jan 07 '18 06:01 netpedro-com

any update?

roysG avatar Apr 01 '19 21:04 roysG

@ocetnik , any update about that?

roysG avatar Apr 01 '19 21:04 roysG