Skip to content

[Bug]: Distance-to-previous-ping readout only tracks TX pings, so Trace and Passive modes anchor it to the session start #501

Description

@MrAlders0n

What happens

Reported from a Trace Mode session: the "distance to previous ping" readout showed several kilometers when the real distance to the previous trace was about 100 m. The value grew while driving away from the session's starting point and shrank when driving back toward it, so it was clearly anchored to the start of the session, not the previous ping. Meanwhile the skip logic behaved correctly: stopping while the readout said "several km" still produced "too close, skipping".

The report came from a pre-1.3.0 dev build, but the defect is still present in the current code.

Why

There are three separate "last ping position" anchors, and the readout only follows one of them:

  • The map readout (map_widget.dart, via AppStateProvider.distanceFromLastPing) reads GpsService._lastPingPosition.
  • _lastPingPosition is only ever set by markPingPosition(), which is called from the TX ping path in ping_service.dart. Nothing in the trace or discovery paths touches it.
  • Trace Mode's own 25 m skip check uses _lastTargetedPosition, and Passive Mode uses _lastDiscoveryPosition, both private to PingService and updated per trace/discovery.

So in a session that sends no TX pings (Trace Mode, Passive Mode), the displayed distance stays measured from wherever the last TX ping happened, which is typically the session start. The skip logic and the readout disagree because they read different anchors.

Suggested direction

Either update the shared display anchor whenever any ping type actually fires (TX, discovery, trace), or make the readout mode-aware so it reads the same anchor the active mode's skip check uses. The first option is a one-line addition in each of the trace and discovery send paths.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions