Android GPS accuracy negatively affected after upgrading to 8.2.0
🔙 Regression
Android GPS accuracy negatively affected after upgrading to 8.2.0
Old (and correct) behavior
Previously on android devices and emulator, listening to a position stream with with best accuracy provided events a few meters apart. For example, when recording a track while walking, each point returned by the stream would be a few meters apart. (about once per second). Behavior observed on physical devices and emulators.
Current behavior
After upgrading to version 8.2.0 the position stream is return points 80+ meters apart (10+ seconds apart) during my testing.
Reproduction steps
Record a track with similar duration/distance before and after upgrading to 8.2.0 on an Android device. If each track has a similar duration and distance, the track recorded on 8.2.0 will have far fewer points (and greater distance between each point) than the track recorded on a previous version. The track recorded on pre 8.2.0 versions will have about 10x more points. IOS seems to retain the same behavior and number of points after upgrading to 8.2.0.
Configuration
Version: 8.2.0
Platform:
- [ ] :iphone: iOS
- [X] :robot: Android
Hi @rlueders
I've tried it now but I don't see the behaviour you are describing when using the emulator. Here is my setup:
final locationSettings = AndroidSettings(
accuracy: LocationAccuracy.best,
intervalDuration: const Duration(seconds: 1),
foregroundNotificationConfig: const ForegroundNotificationConfig(
notificationTitle: "Background Recording",
notificationText:
"Background recording running ",
enableWakeLock: true,
enableWifiLock: true,
),
);
Geolocator.getPositionStream(locationSettings: locationSettings)
.listen(value => print('Position update ' + value.timestamp!.toString()));
and here are the results
I/flutter ( 7077): Position update 2022-02-18 14:40:15.095Z
I/flutter ( 7077): Position update 2022-02-18 14:40:16.105Z
I/flutter ( 7077): Position update 2022-02-18 14:40:17.110Z
I/flutter ( 7077): Position update 2022-02-18 14:40:18.093Z
I/flutter ( 7077): Position update 2022-02-18 14:40:19.119Z
I/flutter ( 7077): Position update 2022-02-18 14:40:20.083Z
I/flutter ( 7077): Position update 2022-02-18 14:40:21.109Z
I/flutter ( 7077): Position update 2022-02-18 14:40:22.071Z
I tested this using both with a foreground notification and without and I received the same results.
In my code I was not specifying an intervalDuration. However, pre 8.2.0, this seems to have defaulted to 1 second, while post 8.2.0 seems to default to about 3 seconds. See testing output and configs below.
Config pre 8.2.0 update: const LocationSettings gpsSettings = LocationSettings( accuracy: LocationAccuracy.bestForNavigation, distanceFilter: 0, );
Output: I/flutter (16242): Position update 2022-02-18 14:57:42.521Z I/flutter (16242): Position update 2022-02-18 14:57:43.521Z I/flutter (16242): Position update 2022-02-18 14:57:44.521Z I/flutter (16242): Position update 2022-02-18 14:57:45.521Z I/flutter (16242): Position update 2022-02-18 14:57:46.521Z I/flutter (16242): Position update 2022-02-18 14:57:47.521Z I/flutter (16242): Position update 2022-02-18 14:57:48.521Z I/flutter (16242): Position update 2022-02-18 14:57:49.521Z I/flutter (16242): Position update 2022-02-18 14:57:50.522Z I/flutter (16242): Position update 2022-02-18 14:57:51.522Z I/flutter (16242): Position update 2022-02-18 14:57:52.522Z I/flutter (16242): Position update 2022-02-18 14:57:53.522Z I/flutter (16242): Position update 2022-02-18 14:57:54.522Z
Config post 8.2.0 update no intervalDuration: const LocationSettings gpsSettings = LocationSettings( accuracy: LocationAccuracy.bestForNavigation, distanceFilter: 0, );
Output: I/flutter (17148): Position update 2022-02-18 15:00:36.551Z I/flutter (17148): Position update 2022-02-18 15:00:39.551Z I/flutter (17148): Position update 2022-02-18 15:00:42.551Z I/flutter (17148): Position update 2022-02-18 15:00:45.551Z I/flutter (17148): Position update 2022-02-18 15:00:48.551Z I/flutter (17148): Position update 2022-02-18 15:00:51.551Z I/flutter (17148): Position update 2022-02-18 15:00:54.551Z I/flutter (17148): Position update 2022-02-18 15:00:57.551Z I/flutter (17148): Position update 2022-02-18 15:01:00.551Z I/flutter (17148): Position update 2022-02-18 15:01:03.552Z I/flutter (17148): Position update 2022-02-18 15:01:06.551Z
Config post 8.2.0 update with intervalDuration :
LocationSettings gpsSettings = AndroidSettings(
accuracy: LocationAccuracy.best,
intervalDuration: const Duration(seconds: 1),
distanceFilter: 0,
);
I/flutter (17381): Position update 2022-02-18 15:06:57.603Z
I/flutter (17381): Position update 2022-02-18 15:06:58.603Z
I/flutter (17381): Position update 2022-02-18 15:06:59.603Z
I/flutter (17381): Position update 2022-02-18 15:07:00.603Z
I/flutter (17381): Position update 2022-02-18 15:07:01.603Z
I/flutter (17381): Position update 2022-02-18 15:07:02.603Z
I/flutter (17381): Position update 2022-02-18 15:07:03.604Z
I/flutter (17381): Position update 2022-02-18 15:07:04.604Z
I/flutter (17381): Position update 2022-02-18 15:07:05.604Z
I/flutter (17381): Position update 2022-02-18 15:07:06.605Z
I/flutter (17381): Position update 2022-02-18 15:07:07.604Z
Looking at the commit history the default behaviour of the intervalDuration was changed in 8.0.4 but that change was not documented in the change log.
@florissmit1 @mvanbeusekom we should maybe just update the change log indicating the behaviour change?
Minimally yes, the change log should be updated. However, the default behaviour of the android and ios versions of plugin are now different, correct? This is not ideal.
On Fri, Feb 18, 2022 at 8:30 AM Hennie Brink @.***> wrote:
@florissmit1 https://github.com/florissmit1 @mvanbeusekom https://github.com/mvanbeusekom we should maybe just update the change log indicating the behaviour change?
— Reply to this email directly, view it on GitHub https://github.com/Baseflow/flutter-geolocator/issues/985#issuecomment-1044706540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ6BSJPC6DIDU2T5AFRWBKDU3ZQ23ANCNFSM5OVJKICQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
@Wackymax @rlueders we're currently looking into it. Since the behaviour on android and iOS are different, we're thinking about rolling back this change, but we're not sure. Thanks for sharing your point of view, I'll keep you up to date!
In the descripition, PR #943 says that intervalDuration is set to 500 (milliseconds) by default. However, in the code, it is actually set to 5000 milliseconds. I wonder which one was the intention; at least this change caused suboptimal behavior in our app (position frequency dropped from 1 second to 5 seconds on library update).
hi, i can confirm that if i change the intervalDuration to 500ms, the delay on android is gone i am on 9.0.2 btw but since its using AndroidSettings, what happens if iOS using this same setting?