Expo keeps stopping when the app is killed while background location methods
See original GitHub issue🐛 Bug Report
Summary of Issue
I registered a task for receiving the location updates in the background using Location.startLocationUpdatesAsync(taskName, options), And defined a task in the global scope using TaskManager.defineTask(taskName, task). The app frequently crashes when killed if the background task is active.
-
The Expo client refuses to start unless clearing its storage on Android.
-
The standalone app starts after at least two trials with a crash message.
Environment
- expo:
^38.0.0 - expo-task-manager:
~8.3.0 - expo-location:
~8.2.1
Screenshot
Steps to Reproduce
1- Location.startLocationUpdatesAsync
2- TaskManager.defineTask
3- Kill the application.
Expected Behavior vs Actual Behavior
- Expected behavior: The running task terminates smoothly.
- Actual behavior:: The running task is killed, and the app can be restarted without a crash message.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:40 (3 by maintainers)
Top Results From Across the Web
Does Expo exposes a quit lifecycle method to handle the ...
I was wondering if Expo exposes any lifecycle method to handle when the app is suddenly killed in the background, for instance, when...
Read more >Location - Expo Documentation
expo -location allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events....
Read more >Expo TaskManager crash when killing app. : r/reactnative
Expo TaskManager crash when killing app. I am running a background task to track locations with Location.startLocationUpdatesAsync().
Read more >expo-location | Yarn - Package Manager
Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.
Read more >AppRegistry - React Native
To "stop" an application when a view should be destroyed, call AppRegistry.unmountApplicationComponentAtRootTag with the tag that was passed ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have tested the background location methods with Expo SDK 39, and I still get the same behavior as before, i.e. the app crashes if it is “swiped” away while the background location task is running. I’ve tested it on emulators with Android 9, 10 & 11, as well as on a real device with Android 11.
I’m really disappointed, as I desperately need this feature to work and had put all my hopes in the new version solving these issues (as described in the CHANGELOG for expo-location / expo-task-manager).
No problem. Something like this is what i have.
Then you run this in your main app navigator when the user is logged into your app. If they are signed out this component will not render and will not try to send background info to the server.