LiveSplitOne icon indicating copy to clipboard operation
LiveSplitOne copied to clipboard

Time is extremely inaccurate if phone goes to asleep

Open kupiakos opened this issue 3 years ago • 3 comments

System: Android 13 Browser: Reproducible on Firefox 116 and Chrome 116. Haven't tested WebView.

Reproduction steps:

  • Start a run at the same time as an external stopwatch.
  • Put the phone to sleep. Closing the browser is not sufficient.
  • Wait at least 10 seconds. 1 minute is enough.
  • Turn on the phone and open LiveSplit One.
  • Compare: LiveSplit will be behind real time by a huge margin, more than 30%, sometimes 80%

kupiakos avatar Aug 25 '23 21:08 kupiakos

This is... a browser bug that's affecting most browsers. And it even goes beyond, it affects most operating systems too. It's crazy how we are in 2023 and this somehow is an issue.

CryZe avatar Aug 25 '23 21:08 CryZe

If it affects most browsers and operating systems, that's not a bug in the browsers/OSs, it's a bug in LiveSplitOne (core?) for relying on APIs that aren't designed to provide reliable time measurements across sleep events.

kupiakos avatar Aug 29 '23 17:08 kupiakos

The problem is that they are designed for that purpose, it's actually in the specification like that and Chrome, Firefox, Safari individually have open bug tickets to fix their implementations. A lot of it is caused by their implementations using the default time tracking coming from the operating systems, which on all except Windows, does not track time across sleep. Linux has an alternative API for a while now, but the browsers aren't using it yet and Apple systems only recently even got an alternative API at all. The bug truly is in the browsers.

Chrome Ticket: https://bugs.chromium.org/p/chromium/issues/detail?id=1206450 Firefox Ticket: https://bugzilla.mozilla.org/show_bug.cgi?id=1709767 Webkit (Safari) Ticket: https://bugs.webkit.org/show_bug.cgi?id=225610

Native livesplit-core does use all the right APIs on each OS. There might be ways to work around the problem in the browsers as well, at the price of other issues.

CryZe avatar Aug 29 '23 19:08 CryZe

While the browsers are all still not spec compliant, I added a mechanism that should fall back to a worse timing mechanism, when the issue happens, which should allow you to track time even when your phone went to sleep.

CryZe avatar Jun 09 '24 21:06 CryZe