You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LocationManager returns a stale "Current Location" after the first fix #164
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.
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.
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 callsstopUpdatingLocation()(OTPKit/Sources/OTPKit/Core/Helper/Location/LocationManager.swift).getCurrentLocation()returns the cachedcurrentLocationwhenever one exists and only callsrequestLocation()when the cache is empty.startLocationUpdates().So after the first fix, every "current location" origin is roughly wherever the rider was at that moment.
Where it shows up
TripPlannerView's.task, when the planner reappears with no origin.CurrentLocationButtonin 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.timestampagainst 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.