-
Notifications
You must be signed in to change notification settings - Fork 231
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
[Bug] bg.BackgroundGeolocation.destroyLocations() crashes the app using the current beta channel version of flutter #70
Comments
I see the problem. The plugin is calling the |
thanks :) |
fwi: /**
* Destory all queued locations in database.
* @param callback
*/
public void destroyLocations(TSCallback callback) {
getThreadPool().execute(new DestroyLocationsTask(callback)); // <-- runs in background-thread
}
private class DestroyLocationsTask implements Runnable {
TSCallback callback;
DestroyLocationsTask(TSCallback _callback) {
callback = _callback;
}
@Override
public void run() {
getLocationDAO(mContext).clear();
getUiHandler().post(new Runnable() { // <-- needs to run callback in main-thread
@Override public void run() { callback.onSuccess(); }
});
}
} |
… When geofence API receives an error, re-register geofences. [Android] disableStopDetection was not implemented.
Fixed in 1.0.8 |
@christocracy it seems not fixed everywhere. I just switched to flutter 1.6 for other things and noted the similar "called not on ui thread" crashes for several callbacks, including ready, start, etc. It appears all callbacks need to be called on the main thread. |
p.s. I was on 1.0.8 |
@livotov The SDK has been careful about executing callbacks on the main thread for the past ~4 years, through the Cordova and React Native versions, where this is important as well. I've updated to flutter dev channel and created a new Hello World app. I see no such issues and the plugin boots fine for both iOS and Android.
Android Boot Log
iOS Boot Log
|
That's interesting. |
For the time being - this is my trace from this morning
|
That seems to come from the insertLocation method. Are you using that method? There could indeed be an issue with this rarely-used method. |
I'm only using the locations() and destroyLocations() methods as our app is using the custom protocol to deliver location points to the backend. Therefore, once all collected points are delivered, I'm calling bg. destroyLocations() method to clean up the plugin database. |
I see there are a few methods executing callbacks on the background thread, including |
If you install the package from Git (branch dependencies:
flutter_background_geolocation:
git:
url: https://github.com/transistorsoft/flutter_background_geolocation.git
ref: odometer |
thanks, it works well so far with the beta channel! |
Hi @christocracy, this seems to still be happening on flutter stable channel I can open a separate issue if you think that would be better than commenting here.
|
Reproduced in flutter Try installing from master dependencies:
flutter_background_geolocation:
git:
url: https://github.com/transistorsoft/flutter_background_geolocation.git |
That fixed it, thank you for getting to that so quick. You're the man! |
published to 1.0.11 |
That's what you pay for: full time support. Sometimes people people wonder why you pay for this plugin, like here. |
@christocracy does 1.0.11 already contains a fix for the similar case location (see below) or this is missed one and needs to be fixed? we're getting crashlytics reports for the build that uses your temp fix branch from above.
|
@christocracy I am still getting a similar issue as well from real devices. Let me know if you want a new issue. From a Galaxy Note 9, running android 9.0, plugin
|
@joserocha3 I see @christocracy is not responding for about 5 days here in issues, so maybe he is temporary out of the office or ill. For the time being, you can fix this manually by accessing the android sources from the plugin cache and fixing the bug. I'm going to do the same now. Later, when the issue will be officially fixed, you can just update the pubspec version and resync the lib. |
@joserocha3 here is the modified java class you can use as well as a temp solution. The place from the crashlog is fixed by wrapping callback with the handler. Just replace the original file with this one and rebuild the app. It should be in your .pub-cache folder: .pub-cache/hosted/pub.dartlang.org/flutter_background_geolocation-1.0.11/android/src/main/java/com/transistorsoft/flutter/backgroundgeolocation/FLTBackgroundGeolocationPlugin.java |
@livotov Yes, I was away all last week. Looking into this today. |
@christocracy great everything alright with you! |
@livotov, @joserocha3 Please try installing from master before I release dependencies:
flutter_background_geolocation:
git:
url: https://github.com/transistorsoft/flutter_background_geolocation.git |
The change works on a Nexus 6 and Pixel 3. The issue presented itself to one of my users on a Note 9. I do not have a Note 9 to test on. |
I reproduced it here on my Samsung A520. |
master looks ok to me. |
Released to |
If the current beta channel version of flutter is used, calling
bg.BackgroundGeolocation.destroyLocations()
leads to a hard crash of the app. See stacktrace below. (Unfortunately, to run your current example app, you have to out-comment all the flutter-map related stuff since that isn't compatible with the beta channel version as well..(see fleaflet/flutter_map#296 and fleaflet/flutter_map#301)Complete stacktrace since launch of the application:
Flutter --version:
The text was updated successfully, but these errors were encountered: