Location.getCurrentPositionAsync() Takes 10+ seconds after upgrading to SDK39 on iOS
See original GitHub issue🐛 Bug Report
I have slow performance on iOS (14), using Expo App (simulator - 11 and real device - 6s) or Standalone (real device - 6s).
Tried to add accuracy to Lowest, but I had same issue.
Works fine on Android.
Environment - output of expo diagnostics & the platform(s) you’re targeting
Expo CLI 3.27.12 environment info:
System:
OS: macOS 10.15.7
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0
Android SDK:
API Levels: 28
Build Tools: 30.0.2
System Images: android-29 | Google Play Intel x86 Atom
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 12.0.1/12A7300 - /usr/bin/xcodebuild
npmPackages:
@expo/webpack-config: ^0.12.16 => 0.12.37
expo: ^39.0.3 => 39.0.3
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz => 0.63.2
react-native-web: ~0.13.14 => 0.13.14
npmGlobalPackages:
expo-cli: 3.27.12
Expo Workflow: managed
Reproducible Demo
import * as Location from 'expo-location';
async function getLocation() {
const start = Date.now();
await Location.getCurrentLocationAsync();
console.log(Date.now() - start); // consistently around 10,100ms
}
Snack reproducible demo -> https://snack.expo.io/@rvieceli/expo-issue-10756
Issue Analytics
- State:
- Created 3 years ago
- Reactions:15
- Comments:54 (12 by maintainers)
Top Results From Across the Web
expo-location's getCurrentPositionAsync() is taking too much ...
In all Android devices it's taking hardly 2 seconds to capture location. But in all iOS devices it takes more than 8 seconds(I...
Read more >Location - Expo Documentation
expo-location allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.
Read more >iOS 15 Settings You Need To Turn Off Now - YouTube
There are several new iOS 15 settings you need to know about, and some older settings have a way of getting turned on...
Read more >How to use the expo-location.getCurrentPositionAsync ... - Snyk
Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events. GitHub. MIT....
Read more >Getting User's Location in iOS - Code with Mosh Forum
I'm using the code at the end of the “Native Features” section in the Ultimate React Native: Advanced course. But, am getting the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@rvieceli I tried passing it balanced as value, and even that value worked for me, a higher value gave problems. This is my code now, including the request for permission to the user:
// Get permissions
const { status } = await Permissions.getAsync(Permissions.LOCATION); if (status !== 'granted') { return; }// Get location
const location = await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Balanced, });Try set accuracy low as below:
const location = await Location.getCurrentPositionAsync({ accuracy: isAndroid ? Location.Accuracy.Low : Location.Accuracy.Lowest, })I set Location.Accuracy.Balanced, which caused long time to get location sometimes. Android does not support Lowest. Although accuracy is low, it was accurate enough, and able to get location much faster than before.
https://forums.expo.io/t/location-getcurrentpositionasync-takes-10-seconds/19714/3