Use the system clock to determine elapsed time #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Rob,
I created a patch to make it use the system clock, rather than relying on receiving every interval, to determine the elapsed time. This allows it to show the true elapsed time even if it missed (or duplicated) some of its timer events, which should make it more accurate.
The main reason I did this was for use on Android and iOS. On iOS, if I go back to the home screen or switch to a different browser tab, the page stops receiving javascript timer events. On Android it manages to send events while in the background, but only until the screen goes to sleep. With the code as it stands, the stopwatch won't advance when it's not receiving events, so you can't trust the time it shows if the page isn't constantly visible. With my patch, it is able to catch up and display the true elapsed time, even if the device has gone to sleep in the middle.
I would also guess that this probably fixes the problem @Blacksus described in #6. I don't know if it actually does fix it, because I never ran into the #6 problem myself. But this patch would make it show an accurate elapsed time, even if the time between the interval events becomes weird.