My app's GPS tracking service kept running after an FCM silent push triggered auto-punchout. The app was killed. The background handler ran, punched the user out, and tried to stop the GPS service. The service ignored it. Battery drained until the user manually opened the app.
The problem wasn't in my code. It was in Tracelet, the GPS tracking library I depend on.
Why Tracelet.stop() doesn't work from a headless isolate
Tracelet is a Flutter GPS tracking library by Ikolvi. My app (Zontra, a field-workforce tracking platform) uses it for all location capture. Tracelet.stop() works fine when called from the main isolate. It uses Pigeon-generated bindings to talk to the native Android service.
Pigeon doesn't work from headless isolates. When Firebase Cloud Messaging delivers a silent push to a killed app, Android spins up a headless Dart isolate with no Flutter engine attached. The Pigeon channel isn't registered there.…