Location.getCurrentPositionAsync() takes 10+ seconds

I upgraded my app to SDK V31. After noticing severely degraded performance related to location-based services, I started profiling to see what was going on. The following consistently takes 10,100 ms to complete:

import { Location } from 'expo';

async function getLocation() {
  const start = Date.now();
  await Location.getCurrentLocationAsync({
    accuracy: Location.Accuracy.Highest
  });
  console.log(Date.now() - start); // consistently around 10,100ms
}

This issue only happens in the standalone production version of my app. In development, there are no issues.

Has anyone experienced this before and know how to fix?

1 Like

Hello orr,
I’m having the same problem. I upgraded to v32 from v28 and my geolocation now takes 10+ seconds on IOS (dev build, haven’t tried prod). Did you find a solution?

Gabriel.

1 Like

Try set accruacy low as below:

const location = await Location.getCurrentPositionAsync({
    maximumAge: 60000, // only for Android
    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.

6 Likes

Hi herbertlim,
That works great. It takes about 100ms to find a geolocation. It’s finding my location without issues, but I’m sitting in my office and have great wifi.
I’m going to prioritize speed in this case and check the results, since 1 Km is a little excessive in terms of accuracy loss. I’m not even going to try the lowest accuracy, 3 Km is way too much.

I wonder which one of the new accuracy constants is equivalent to the old high accuracy settings of past Expo versions, since I never had any issue with speed before.

Thanks!

I did some tests and found that the accuracy was much better than documentation. :slight_smile:

2 Likes

@herbertlim, THANK YOU. That resolved the issue.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.