Skip to content

LocationManager returns a stale "Current Location" after the first fix #164

Description

@aaronbrethorst

Problem

LocationManager.getCurrentLocation() returns a location that can be stale for the whole app session, labelled "Current Location".

  • locationManager(_:didUpdateLocations:) caches the fix and immediately calls stopUpdatingLocation() (OTPKit/Sources/OTPKit/Core/Helper/Location/LocationManager.swift).
  • getCurrentLocation() returns the cached currentLocation whenever one exists and only calls requestLocation() when the cache is empty.
  • Nothing in the package or demo calls startLocationUpdates().

So after the first fix, every "current location" origin is roughly wherever the rider was at that moment.

Where it shows up

  • End Trip (Fix: Find Routes disabled after ending a trip #162): the origin is restored to "Current Location" right after the rider has traveled, so Find Routes silently plans from the wrong place.
  • TripPlannerView's .task, when the planner reappears with no origin.
  • CurrentLocationButton in the location search sheet.

The simulator doesn't reproduce this unless you move the simulated location mid-session.

Possible fix

Treat the cache as fresh only within a short window, for example by checking CLLocation.timestamp against a max age and requesting a new fix otherwise. Or keep updates running while the planner is visible.

Related

The reset-during-lookup guard and injectable location provider (with tests) from #162's commit cf7c2d5 were trimmed before merge. They'd pair naturally with this fix.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions