Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App ceases to fire onLocation event about 8 minutes after entering background #192

Closed
MatKershaw3708 opened this issue Aug 31, 2023 · 8 comments
Labels

Comments

@MatKershaw3708
Copy link

MatKershaw3708 commented Aug 31, 2023

Your Environment

@transistorsoft/capacitor-background-geolocation 5.1.2
Android 13
Pixel 6a
Capacitor dependencies 5.3.0

const config = {
reset: true,
debug: false,
desiredAccuracy: BackgroundGeolocation.DESIRED_ACCURACY_HIGH,
distanceFilter: 3,
stationaryRadius: 25, // Enforced minimum 25, less would be good for our use case
stopTimeout: 120
stopOnStationary: false,
isMoving: true,
motionTriggerDelay: 1000,
fastestLocationUpdateInterval: 1000,
};

Expected Behavior

App is a walking/jogging tracker and should be able to enter background with screen off and use the onLocation callback to check if user is within set distance of pre-defined lng-lat checkpoints, to trigger a sound and vibration confirmation. It needs to continue doing so for up to 12 hours. Device is used for competitive events so users need immediate confirmation of their presence at a checkpoint to avoid backtracking.

Actual Behavior

App ceases to sound/vibrate within approx 8 minutes of screen being off, and instead processes all the callbacks at once when the app gets focus again. The plugin clearly is continuing to store locations/events, but seems to cache the actual execution of the callbacks while the app is in the background. The locations are correct but the time recording is off as it uses the device time at the moment the callback executes.

##Context
This seems to be a situation similar to those described in other open issues, but I wanted to provide an exact description. This is new behavior that also affects our Capacitor 4 build, it worked well until about 6 months ago?

@MatKershaw3708
Copy link
Author

Just like to add that all battery optimization etc is off, and TSLocationManager has notification permissions.

@christocracy
Copy link
Member

See wiki "Debugging". Learn to fetch and observe logs from the plugin.

Also see Wiki "Philosophy of Operation"

@MatKershaw3708
Copy link
Author

MatKershaw3708 commented Sep 1, 2023

The dubug sounds indicate that the plugin is firing the LOCATION_RECORDED sound every couple of seconds when walking, as expected. No 'sad' sounds such as ERROR or WARNING, and at no point does it enter the non-moving state.

It does however stop executing the onLocation callbacks after five minutes or so, only to fire them all at once when the app comes in to the foreground. The callback code works exactly as expected, just all at once.

Are able to tell me whether this is intentional or unintentional behaviour your end?

@christocracy
Copy link
Member

The plugin has no control over what happens to events once provided to Capacitor. Sounds like WebView issues. That's completely beyond the plugin's responsibility.

Your problem sounds like this.

I'm sure the plugin's native HTTP requests do not get queued (you are not configuring an url, so there are no native HTTP requests in your case), evidenced by the continued emissions of Debug Sound FX.

@MatKershaw3708
Copy link
Author

Thanks that's really useful - I presumed Capacitor had its own JS instance rather than relying on the Webview for execution. It might be time to migrate to Flutter...

I've solved the incorrect timestamps issue by using those provided by the location object, but I guess we can't do background events in Capacitor any more.

@christocracy
Copy link
Member

It might be time to migrate to Flutter...

It's my preferred framework. I do all my SDK development primarily in flutter. React Native doesn't use a WebView, either.

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 17, 2024
Copy link

github-actions bot commented May 1, 2024

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants