LiveSplit / LiveSplitOne

A version of LiveSplit that works on a lot of platforms.
https://one.livesplit.org/
MIT License
243 stars 28 forks source link

Time is extremely inaccurate if phone goes to asleep #800

Closed kupiakos closed 3 months ago

kupiakos commented 1 year ago

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

Reproduction steps:

CryZe commented 1 year ago

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.

kupiakos commented 1 year ago

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.

CryZe commented 1 year ago

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 commented 3 months ago

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.