flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Bug]: Infinity loading and time out on getting current location

Open Samin-roadsurfer opened this issue 6 months ago • 3 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [x] Android
  • [x] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Steps to reproduce

  1. I use real android/ios device
  2. I open the app and choose "Only this time"/"While using the app"
  3. it works most of the time for the first time, but if you clear the location and call it again it stucks.

Expected results

I expect location to be determined without any problems.

Actual results

Application loads infinitely since the location can not be determined and then time out.

also sometimes i try to get it frequently, i get :

D/permissions_handler(26103): No permissions found in manifest for: []25

Code sample

Code sample
await Geolocator.getCurrentPosition(
      locationSettings: const LocationSettings(
        accuracy: LocationAccuracy.medium,
        timeLimit: Duration(seconds: 20),
      ),
    );
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

Screenshots or video

Screenshots or video demonstration

https://github.com/user-attachments/assets/6073f44a-0959-4483-a939-e5cd1d287069

Version

geolocator: ^14.0.0

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4 24E248 darwin-arm64, locale en-DE) [2.5s]
    • Flutter version 3.29.3 on channel stable at /Users/saminsheyda/fvm/versions/3.29.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (6 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [4.5s]
    • Android SDK at /Users/saminsheyda/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [7.0s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [11ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [10ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)

[✓] VS Code (version 1.83.1) [9ms]
    • VS Code at /Users/saminsheyda/Downloads/Visual Studio Code 2.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] VS Code (version 1.80.0) [9ms]
    • VS Code at /Users/saminsheyda/Downloads/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (5 available) [8.9s]
    • Samin Sheyda’s iPhone (mobile)  • 00008120-0012701026A1A01E            • ios            • iOS 18.5 22F76
    • iPhone 16 Pro (mobile)          • 9E564AC3-FE5C-49E9-B91E-4348E02BD034 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.4 24E248 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.4 24E248 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 136.0.7103.114

[✓] Network resources [451ms]
    • All expected network resources are available.

• No issues found!

Samin-roadsurfer avatar May 26 '25 09:05 Samin-roadsurfer

@Samin-roadsurfer,

Thanks for your issue, does this happen to iOS and Android, since they both have a different implementation. Can you try to test the same with the example app to see if you have a different outcome?

Kind regards,

TimHoogstrate avatar May 28 '25 07:05 TimHoogstrate

Hey @TimHoogstrate thanks for checking the issue :) here the debug result of example app with same code mentioned in the main issue:

android: Image

ios: could not reproduce the issue on example app for ios, but i do see it in my main app sometimes.

Samin-roadsurfer avatar May 28 '25 08:05 Samin-roadsurfer

Dear @Samin-roadsurfer,

This looks like a different issue. It looks like your device was unable to determine a location in the given timeout time. Please add your used settings so that we can check if there might be a theoretical reason why this takes so long. Furthermore, I think that your permissions issue can be resolved by reading the documentation on what you should do in order to get the correct permissions. You can open the example app and your app side by side to see that you have different. In iOS the info.plist and pod file are important first steps. In Android the Manifest file is important to check.

Kind regards,

TimHoogstrate avatar Jun 03 '25 13:06 TimHoogstrate

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

github-actions[bot] avatar Jun 17 '25 13:06 github-actions[bot]