runnerup icon indicating copy to clipboard operation
runnerup copied to clipboard

Workout time starts when GPS is started instead of when workout is started

Open samontab opened this issue 2 years ago • 3 comments

If you start the GPS but don't start the workout immediately afterwards, you will see that when you start running there is already some amount of time there. That's the time since the GPS started.

Ideally you would only start counting the workout time from the moment you press start, not when the GPS is started.

samontab avatar Jan 08 '24 11:01 samontab

I have this issue as well. Once the GPS is first started and has has a signal, the problem occurs for me if I leave the app (ex. return to the home screen, start another app on top of RunnerUp, or turn of the phone screen). It is like the GPS then gets disconnected, but the notification still shows the "Ready to start running!" message and when returning to the app, it is still in the "start" state. When starting the workout it seems GPS needs to get connected again before the workout is started (but as @samontab says the time is since the GPS first was started).

EDIT: I have a Pixel 6 running Android 14.

roberi avatar Jan 25 '24 16:01 roberi

I've looked into this a bit more. I am still not sure it is exactly the same issue as @samontab, but after clicking the "Start GPS" button, the app stops receiving location updates if it is no longer in the foreground. I found it is a behavior change starting with Android 8. The video below demonstrates this by logging the time difference since the last location update (should be about once every second).

For some devices, it seems it can take some time to start receiving location updates again. Perhaps when at a location with a poor GPS signal? If a user then clicks on the "Start" button before location updates are delivered again, this delay (between the last location when the app went to background and location updates starts again) gets added to the time (about 12 seconds in the video).

When testing on an emulator running Android 7 (the version before the behavior change), the app works as expected as location updates never stops. If the user clicks on the "Start" button after location updates are being delivered again, the app works as expected.

Possible fixes?

  • Use a foreground service to keep receiving location updates when not in the foreground.
  • Set state to "GPS searching" when not in the foreground.
  • Other?

https://github.com/user-attachments/assets/d9284c9c-b498-4469-8bab-0ae0c46c1dc6

roberi avatar Jul 18 '24 20:07 roberi

When time is started a location point with the last known location is logged. The time is replaced with the current system time. GPS and system may differ,there is an override to always use system time (that is now the default). If there is no fix with the time override, I assume a foreground servive is preferred, so GPS is good when actually starting.

gerhardol avatar Jul 19 '24 16:07 gerhardol