-
-
Notifications
You must be signed in to change notification settings - Fork 692
Geolocator.getCurrentPosition() method takes too much time to return its position #559
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Did you enable assisted location services in the system settings of the phone? Depending on that setting and perhaps the GPS coverage in your area, location retrieval can take a while. |
Hello. Similar happens with version 6.1.0 both on Samsung S10+ (Android 10) and iPhone 8 (iOS 13.7). Thanks |
yes, I have good Internet connection and enabled location services in settings |
Hi @balajiramadoss, This is a bit hard to debug, I have gone over the implementation on my side a few times and I feel this is a problem related to the hardware. Also I don't experience this problem in my tests (on emulator or on the one LG Nexus 5x I own). As @ened mentioned it can take a while for your phone to acquire a GPS link and retrieve it's current location. Could you check if once the device has acquired a GPS fix, subsequent calls to the Some workarounds that might help are:
I am open for any other suggestions and feel free to go through the code and give (constructive) feedback. |
I wanted to add that I am facing a similar situation. I am passing in a 10 second timeout, and it progresses well beyond 10 seconds and never returns (or throws an exception). I was previously using version 5.1.1+1 without issue, but I upgraded to the most recent version to be able to pass in the timeout value. After upgrading, I did 'flutter clean' before building, just in case. Some other information that may be relevant: when my application starts, I am setting up a position stream via Geolocator.getPositionStream with the relevant parameters for my situation. The stream is used for location recording, but I have a diagnostics type screen where I call Geolocator.getCurrentPosition to display the most accurate and up-to-date position along with other hardware information. In version 5.1.1+1, I had no problems having a stream active while calling getCurrentPosition. I updated my diagnostics screen to call getLastKnownPosition instead, and that returned immediately. I'd really rather have a confirmed current position, but since it is not presently working, I'm falling back to the last known position. The original poster did not indicate whether a stream was already active or not, but it might add some additional insights to the issue. |
@zarfleen version 5 of the geolocator had a bug which might explain why it (seemed) to be fast. The problem was that when calling the Strangely enough nobody noticed it and I realized the mistake when rebuilding the plugin into version 6. Maybe you can confirm you were using the Currently we do have an issue where the |
@mvanbeusekom I was not using One thing of note: I was recently working on a different project where I was using the |
Also this method never returns the Exception when it crosses the timeLimit |
@zarfleen I have just released version 6.1.2 of the geolocator which contains a fix for issue #546, I would really appreciate it if you could run some tests and see if this also solves your issues? |
@mvanbeusekom I tested with 6.1.2 and now |
Awesome thanks a lot for testing and the feedback! |
I get this error: E/flutter (18928): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: The location service on the device is disabled. |
@ViniciusDS you will receive this error when the location services on the device are disabled (or are being disabled during while the stream is active). You can use the Hope this helps. If you keep experiencing issues, please create a separate issue and I will be able to help you there. |
I'm running into a similar problem with getCurrentPosition Timing out except mine is crashing entirely here.
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: TimeoutException after 0:00:00.000000: Future not completed I'm using the latest version. We'd updated from version geolocator: ^5.1.3 and can confirm we were using forceAndroidLocationManager. Any help would be greatly appreciated. We're going to attempt to roll back for now as this is preventing our app from working at all currently. |
Had to run a flutter pub upgrade, but I see the update now. geolocator: Looks to be working. I have it wrapped as follows just in case but it's not tripping on the error anymore.
Thanks for quick update! |
I have this problem too, what is the current solutionn for that? |
forceAndroidLocationManager: true, |
Updating to the latest version 8.2.1, resolved the issue for me |
🐛 Bug Report
The method Geolocator.getCurrentPosition() takes too much time to get the position (almost more than 2 minutes sometimes even more)
Reproduction steps
Device Configuration - Moto G5 S Plus Android 8.1 Oreo
Version: 6.1.1 of Geolocator
Platform:
The text was updated successfully, but these errors were encountered: