getCurrentPositionAsync() is taking too much time to fetch location in iOS devices

Hello @amanhimself

I’m using the code sample from the documentation in my project:

import React, { useState, useEffect } from 'react';
import { Platform, Text, View, StyleSheet } from 'react-native';
import * as Location from 'expo-location';

export default function App() {
  const [location, setLocation] = useState(null);
  const [errorMsg, setErrorMsg] = useState(null);

  useEffect(() => {
    (async () => {
      let { status } = await Location.requestForegroundPermissionsAsync();
      if (status !== 'granted') {
        setErrorMsg('Permission to access location was denied');
        return;
      }

      let location = await Location.getCurrentPositionAsync({});
      setLocation(location);
    })();
  }, []);

  let text = 'Waiting..';
  if (errorMsg) {
    text = errorMsg;
  } else if (location) {
    text = JSON.stringify(location);
  }

  return (
    <View style={styles.container}>
      <Text style={styles.paragraph}>{text}</Text>
    </View>
  );
}

The problem is NOT reproductible on Android or ios Emulator but is when in testflight for example from all the iphones tried.

For information I have seens multiple mention of this problem on discord, also it is in this github thread Location.getCurrentPositionAsync() Takes 10+ seconds after upgrading to SDK39 on iOS · Issue #10756 · expo/expo · GitHub or also this forum thread Location.getCurrentPositionAsync() takes 10+ seconds - #3 by herbertlim . Some alternative have been mentionned but nowhere have I found a reason/solution.

For me, lowering the accuracy did not make it faster but did indeed lost in precision.

I have an older version of the app on SDK 42 and expo-location 10 and it works perfectly (fast and precise) on the exact same iphones where now it takes 10sec +.

IMPORTANT EDIT: An important info I just tested, using Location.watchPositionAsync(options, callback) instead of Location.getCurrentPositionAsync with the same implementation works fast on the exact same Iphones (we get precision and fast coordinates) which confirms that there is most probably a bug in the Location.getCurrentPositionAsync method.