Recording GPS in the background on iOS without losing the ride
iOS can suspend or terminate your recorder at any moment and owes you no warning. What that means for an app that is supposed to be writing down where you went, and what actually protects a ride.
You start a recording, put the phone in a pocket, ride for three hours, take it out, and the app shows twenty minutes. This is the single most common serious complaint about phone-based trackers, and the cause is almost never the GPS.
What iOS is actually doing to your app
An iOS app in the background is not simply running slower. It moves through states: still running, suspended (frozen in memory, executing nothing), and terminated (gone). The system moves you between them based on memory pressure, thermal state, battery and its own judgement, and it is not obliged to tell you in advance.
An app with the location background mode gets to keep running while location updates are arriving, which is how any of this works at all. That is a strong guarantee compared to a normal app. It is not an absolute one: under real memory pressure — a big game, a camera app, a phone with less RAM — your recorder can still be killed mid-ride.
This produces the failure that matters. If the app was holding the ride in memory, waiting for you to press stop before it wrote anything down, then everything since the last save is gone. Not corrupted. Gone, with no error, because the process that knew about it no longer exists.
The only real protection: write it down as it arrives
There is no clever way around this. The protection is to never have unsaved data in the first place.
In Roam, one location callback is one batch is one database transaction, and the points and the ride’s running totals are committed together. There is no buffer waiting for the end of the ride, and no path in the writer that drops a point quietly — a batch that cannot be committed raises an error and is parked in an alarm rather than absorbed. If the app is killed at kilometre forty, kilometre forty is already on the phone.
Committing the totals in the same transaction as the points matters more than it looks. It means the summary row can never describe a set of points that is not on disk, so after a kill there is no window where the two disagree — and recovery does not have to replay twenty-eight thousand points to work out where you were. It reads the row.
The other half of the same idea: nothing is ever deleted. Filtering, smoothing and auto-pause never remove a row from the database. They are recorded as flags on the point, and the raw stream stays exactly as it arrived, so that when a heuristic gets a real ride wrong the original samples are still there to re-derive from. An app that quietly discards the samples it disagreed with has destroyed the evidence that it was wrong.
Getting back up after a termination
If you granted location Always, iOS can relaunch a terminated app in the background when a significant location change occurs. This is a genuine lifeline, and it comes with a trap that has bitten a great many recorders.
On that relaunch the app has a very short, unpredictable window before the system may suspend it again — and crucially, it may be suspended at any suspension point, which in modern Swift means at any `await`. An app that relaunches and then asynchronously loads some state before rebuilding its location manager can be frozen partway through, and a process suspended before it re-armed will never hear from the GPS again. It appears to be running. It is receiving nothing.
Roam’s re-arm is deliberately synchronous for exactly this reason: rebuilding the location manager and restarting updates happen before the first await, which makes the mistake impossible to introduce rather than merely discouraged. It is also written to be safe to call twice, because a background relaunch racing a foreground launch will do precisely that.
Worth being clear: Always is insurance, not a requirement. Recording works fine with While Using, and the app says so in the permission prompt rather than implying you have to hand over the stronger permission.
And it is insurance rather than a guarantee, which is a distinction worth insisting on. Roam’s own configuration states the assumption in as many words — it may never be relaunched, and durability is the only promise it makes. Nothing in iOS obliges the system to bring a terminated app back. Whatever happened between the kill and the relaunch was not recorded by anyone, and no API can hand it over afterwards, so what you get back is the ride up to the kill plus the ride after the relaunch, with an honest hole between them. Any app that describes this as seamless continuation is describing something the platform does not provide.
What the rider can do
- Grant location Always if you are recording anything long. It is the difference between a termination costing you nothing and costing you the rest of the ride.
- Leave Low Power Mode off if you can. It makes background work more likely to be curtailed.
- Do not swipe the app away from the app switcher mid-ride. Force-quitting tells iOS you meant it, and no background relaunch will occur.
- Do not run a second recorder at the same time. Two apps holding the GPS awake doubles the drain and the memory pressure that gets one of them killed.
- Check the permission after an iOS update. Upgrades occasionally downgrade Always to While Using without much ceremony.
How to tell whether your recorder is safe
You can test this in ten minutes without any special tools. Start a recording, walk for five minutes, then force-quit the app from the app switcher and reopen it. If the five minutes are there, the app was writing as it went. If the ride is empty or truncated, it was holding your data in memory and you now know exactly how much of a long ride you stand to lose.
A recorder should also declare as little as possible. Every extra background mode is something the app can be terminated for misusing and something an App Store reviewer will ask about; Roam declares one — location — and the repository contains a build gate that fails the build if that list ever grows by a single entry.
Frequently asked questions
Why did my iPhone stop recording my ride in the background?
Almost always because iOS suspended or terminated the app under memory pressure, or because it was force-quit from the app switcher. The location background mode keeps a recorder alive far longer than a normal app, but it is not an absolute guarantee, which is why what the app does with each fix matters more than staying alive.
Does an app need Always location to record a ride?
No. While Using is enough to record with the screen off, because the location background mode keeps the app running while updates arrive. Always adds the ability for iOS to relaunch the app in the background if it was terminated, so it is insurance for long rides rather than a requirement.
Does background GPS drain the battery?
It uses real power — the receiver runs continuously and the app wakes for every fix. A modern phone handles a multi-hour ride comfortably; an all-day event is where it becomes a question, and where an app that writes as it goes is the difference between losing the last minutes and losing the day.
How can I test whether my recorder loses data?
Start a recording, walk for five minutes, force-quit the app from the app switcher, and reopen it. If those five minutes survived, the app writes as it goes. If they did not, it was keeping your ride in memory.
A recorder that does not lose the ride
Roam commits every GPS fix to the phone the moment it arrives, marks signal gaps instead of drawing a straight line through them, and reads climb from the barometer rather than from GPS altitude. No account, no sign-in, no sync. Recording a ride, viewing it and replaying it are free.