-
Notifications
You must be signed in to change notification settings - Fork 281
[Help Wanted]: Error when launching app #1664
Description
Required Reading
- Confirmed
Plugin Version
5.0.5
Mobile operating-system(s)
- iOS
- Android
Device Manufacturer(s) and Model(s)
Motorola G05 Xiaomi Redmi A9
Device operating-systems(s)
Android 10, 11, 15
What do you require assistance about?
We're seeing a race condition between ready() and start(). The error doesn't break location tracking (GPS works fine despite the exception), but it generates errors in our logging.
Plugin version: 5.0.5
Our code:
final config = Config(
desiredAccuracy: Config.DESIRED_ACCURACY_MEDIUM,
stopOnTerminate: true,
startOnBoot: false,
enableHeadless: false,
foregroundService: true,
distanceFilter: 20,
locationUpdateInterval: 25000,
heartbeatInterval: 2700,
isMoving: true,
);
final state = await BackgroundGeolocation.ready(config);
BackgroundGeolocation.onLocation(_onLocation, _onLocationError);
BackgroundGeolocation.onHeartbeat(_onHeartbeat);
if (!state.enabled) {
await BackgroundGeolocation.start(); // throws PlatformException
}
Error:
PlatformException(Waiting for previous start action to complete, null, null, null)
What we observe:
- ready() succeeds and returns state.enabled = false
- start() throws immediately with the above exception
- Despite the error, location tracking works correctly — all devices emit location data to our backend
Context — kiosk-mode app:
Our app runs as an Android Device Owner (kiosk-mode launcher) on elderly users' devices. The problem occurs when we start the app when we turn on the device.
Questions:
-
What would you recommend to make the initialization more resilient in our scenario? We currently call ready() followed by start(), but as described, the race condition causes false errors.
-
We have distanceFilter set to 20 meters with locationUpdateInterval at 25000 ms. For our use case (elderly users, mostly stationary at home with occasional outings), we've noticed that when the user is on public transport, the location doesn't update correctly — the reported position can lag by hundreds of meters from the actual location. Would you recommend lowering distanceFilter and/or locationUpdateInterval to improve tracking during movement, or is there a better approach ?