You can measure time in one of two different ways. One: adding a second every 1000 milliseconds to the timer. Two: taking the elapsed time between a given point in the past and the current time. The first method produces terrible results because when the tab is in the background, it isn't always updated, and a one-second delay ends up being two seconds on average. The second method works flawlessly, regardless of the state of the tab. Even without looking at the actual code, you can clearly guess which method is used here.