OpenTracksApp / OpenTracks

OpenTracks is a sport tracking application that completely respects your privacy.
https://OpenTracksApp.com
Apache License 2.0
1.06k stars 190 forks source link

Moving and total time reset several times during activity #1178

Closed brianjmurrell closed 2 years ago

brianjmurrell commented 2 years ago

Describe the bug During an indoor (GPS off) activity, I noticed that the timer(s) reset to 0 during the activity. At the end of the 1hr activity, the total time was only 38:43.

To Reproduce Unknown

If applicable:

Technical information

@@ -165,6 +165,11 @@ public class BluetoothUtils { index = 3; if (valueLength - index >= 1) { cadence = Cadence.of(characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, index)); +

diff --git a/src/main/java/de/dennisguse/opentracks/stats/TrackStatistics.java b/src/main/java/de/dennisguse/opentracks/stats/TrackStatistics.java index daa81800e..0da3ac100 100644 --- a/src/main/java/de/dennisguse/opentracks/stats/TrackStatistics.java +++ b/src/main/java/de/dennisguse/opentracks/stats/TrackStatistics.java @@ -16,9 +16,12 @@

package de.dennisguse.opentracks.stats;

+import android.util.Log; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; +import android.util.Log;

import java.time.Duration; import java.time.Instant; @@ -232,7 +235,12 @@ public class TrackStatistics { }

 public void addMovingTime(TrackPoint trackPoint, TrackPoint lastTrackPoint) {

Indeed, the GPX file has a number of trksegs in it with some disturbing gaps:

<time>2022-04-10T14:44:34.649-04:00</time>
...
</trkpt>
</trkseg>
<trkseg>
...
<time>2022-04-10T14:51:13.642-04:00</time>
...
<time>2022-04-10T14:54:10.647-04:00</time>
...
</trkpt>
</trkseg>
<trkseg>
...
<time>2022-04-10T14:59:42.632-04:00</time>
...
<time>2022-04-10T15:00:45.647-04:00</time>
...
</trkpt>
</trkseg>
<trkseg>
...
<time>2022-04-10T15:04:15.642-04:00</time>
...
<time>2022-04-10T15:07:38.644-04:00</time>
...
</trkpt>
</trkseg>
<trkseg>
...
<time>2022-04-10T15:10:10.639-04:00</time>
...
<time>2022-04-10T15:17:48.632-04:00</time>
...
</trkpt>
</trkseg>
<trkseg>
...
<time>2022-04-10T15:21:26.642-04:00</time>
...

I'm fairly sure the app continued running through those fairly large gaps. I'm fairly sure I would have noticed at least one of those.

There is nothing in logcat between those gaps though.

dennisguse commented 2 years ago

Were you using the TICKR X? And can you check the KML? There are same workarounds for GPX in place.

dennisguse commented 2 years ago

@brianjmurrell :point_up_2:

brianjmurrell commented 2 years ago

Were you using the TICKR X?

Yes.

And can you check the KML?

Check it for what exactly?

There are same workarounds for GPX in place.

But to be clear, the multiple segments in the GPX are just a symptom and confirmation of what I saw on the display during the activity and that's that the timer for the activity reset back to zero during the activity -- a number of times.

So this is not a GPX export problem. This is an activity-timer-reset problem. Just in case I had confused this issue with the GPX aspect of it.

dennisguse commented 2 years ago

Thanks. In the GPX the TrackPoints are merged together that do not have a GPS coordinate as GPX doesn't allow this - and this merging might lead to the generation track segments (as the max. recording distance threshold is reached).

If you export the data as KML/KMZ, you get the actual TrackPoints that were recorded. And it would be interesting to see "original" data (technically, we might still be missing things as those were ignored) as it allows to investigate the issue.

And I would love to see a screen recording.

In theory, we do not have any timer - so there might be some other effect that we do not want to have.

brianjmurrell commented 2 years ago

The KML shows multiple tracks:

...
        <gx:Track>
          <when>2022-04-10T14:44:02.913-04:00</when>
...
        <gx:Track>
          <when>2022-04-10T14:51:13.642-04:00</when>
...
        <gx:Track>
          <when>2022-04-10T14:59:42.632-04:00</when>
...
        <gx:Track>
          <when>2022-04-10T15:04:15.642-04:00</when>
...
        <gx:Track>
          <when>2022-04-10T15:10:10.639-04:00</when>
...
        <gx:Track>
          <when>2022-04-10T15:21:26.642-04:00</when>
...

And I would love to see a screen recording.

Of what? The time resetting back to 0 during the activity? That would be difficult. I didn't even see it, the moment it reset. I only noticed some time after that the time was less than it was when I last looked.

In theory, we do not have any timer - so there might be some other effect that we do not want to have.

Well, there is a timer timing the length of the activity from start to end. That's the timer I am referring to.

dennisguse commented 2 years ago

It looks like as some if the TrackRecordingService crashed and that due to an onResume() in the TrackRecordingActivity (e.g., it went into background and back into foreground or the display was turned off and on again) started a new track.

~~And this functionality is implemented and it must be replaced for #1103. Now the question would be: what could cause the crash like this?~~

dennisguse commented 2 years ago

@brianjmurrell forget what I said. A gx;Track is also just a segment. And a new segment is created, if the distance was larger than the threshold (default 200m).

And now the magic: speed/distance sensors (cycling as well as running) have a monotonic counter (some reset on standby; some never). During recording, OpenTracks receives this absolute and makes it relative to the first received data in this recording. So, if the sensor is running it will accumulate the distance and if OpenTracks is not (a) accepting [e.g., standby, etc] or (b) not storing, it will be stored when OpenTracks reconnects (and the recording is still running).

As the sensor does the distance storing, it will not affect the distance. Moving time will way below the expectation as less TrackPoints were actually stored (and only stored once are used for computing track statistics).

Why the UI reset to 0 sometimes and the overall time is less than expected, I don't know. Probably some (usually hidden) bug in TrackStatisticsUpdater.

Best guess: some Android power management issue. https://dontkillmyapp.com/

brianjmurrell commented 2 years ago

The one thing it is NOT is Android power management. The phone's screen was on with OpenTracks as the active application for the entire duration of the activity, while the phone was sitting in front of me on the treadmill console when this happened.

dennisguse commented 2 years ago

Then I don't know what the reason - just that the sensor did not send or they disconnected. Not really sure what to do about it then.

dennisguse commented 2 years ago

@brianjmurrell Any more insights here?

brianjmurrell commented 2 years ago

Not really. I have not seen it happen since the one time. Maybe I'll close this and can re-open if it recurs.