Baseflow / Baseflow/flutter-geolocator

[WEB] Firefox mobile (Android) browser changes location from allowed to blocked

Open
#1,120 0 comments 0 reactions 0 assignees View on GitHub
P2 platform: web type: bug
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

## 🐛 Bug Report

Firefox mobile browser changes location from allowed to blocked when using Geolocator.getPositionStream() or calling Geolocator.getCurrentPosition() too many times and too fast. It seems to work fine if there is delay between Geolocator.getCurrentPosition() calls.

Phone: Galaxy S8
Android: 9

### Expected behavior

Firefox shouldn't bloc location when it's allowed when using Geolocator.getPositionStream() .

### Reproduction steps

Added button with onPressed: () { _determinePosition(); }: It seemed to work fine if I was pressing slowly but if I was pressing too fast Firefox blocks location. Same happens when using StreamBuilder Geolocator.getPositionStream().

```
Future _determinePosition() async {
bool serviceEnabled;
LocationPermission permission;

// Test if location services are enabled.
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
// Location services are not enabled don't continue
// accessing the position and request users of the
// App to enable the location services.
return Future.error('Location services are disabled.');
}

permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
// Permissions are denied, next time you could try
// requesting permissions again (this is also where
// Android's shouldShowRequestPermissionRationale
// returned true. According to Android guidelines
// your App should show an explanatory UI now.
return Future.error('Location permissions are denied');
}
}

if (permission == LocationPermission.deniedForever) {
// Permissions are denied forever, handle appropriately.
return Future.error(
'Location permissions are permanently denied, we cannot request permissions.');
}

// When we reach here, permissions are granted and we can
// continue accessing the position of the device.
print("Position: ${await Geolocator.getCurrentPosition()}");
}
```

### Configuration

Version: 8.2.1

**Platform:**
- [ ] :iphone: iOS
- [x] :robot: Android

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue on Firefox mobile for Android with Geolocator 8.2.1, using repeated getCurrentPosition() calls and getPositionStream(). Compare slow and rapid calls, then trace the web geolocation and permission handling involved. Done means allowed location remains usable during rapid calls without Firefox changing it to blocked.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, flutter
Domain
mobile-dev, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.