react-native-geolocation-service icon indicating copy to clipboard operation
react-native-geolocation-service copied to clipboard

Reintroduced Performance Issue on iOS (locations taking 10 seconds).

Open NoahFace opened this issue 1 year ago • 6 comments

Unfortunately this issue:

https://github.com/Agontuk/react-native-geolocation-service/issues/212

with iOS performance (taking 10 seconds to get locations) has been re-introduced when the code has been refactored.

The following code change is needed: locationManager.startUpdatingLocation() //requestLocation()

to line 61 of the file locationProvide.swift

For now I have created a local build to fix the issue (again!). Please fix the issue again.

NoahFace avatar Dec 09 '22 20:12 NoahFace

I can confirm the issue is happening. Turning off precise location also fixes. @NoahFace is there any difference between startUpdatingLocation and requestLocation in terms of the results that are returned?

iamjon avatar Dec 11 '22 10:12 iamjon

This is the commit that re-introduced the error: 1f8e3942458d801c6f96fa06a9d45f35765b8d9f

I also found this on stacked overflow that discusses startUpdatingLocation() vs requestLocation()

https://stackoverflow.com/questions/39499541/cllocationmanager-requestlocation-takes-about-10-seconds https://stackoverflow.com/a/57372856

TL;DR requestLocation() is a convenient method provided by Apple which under the hood will run startUpdatingLocation() , retrieve multiple location data, and select the most accurate one to pass to delegate, and call stopUpdatingLocation() This process can take up to 10 seconds (which is around the timeout limit) if it can't decide which location data is the best.

iamjon avatar Dec 11 '22 11:12 iamjon

I have verified that, as @iamjon indicated, that setting enableHighAccuracy=false also avoids the issue. I don't think this was the case in earlier versions (based on my comments in the previous issue thread and my recollection, but my earlier comments are not 100% clear). I think either iOS has changed in more recent versions OR the way that this library was mapping enableHighAccuracy -> iOS accuracy has changed (I think its the latter - the code is quite different).

So, there are potentially two solutions: i) Just change requestLocation back to startUpdatingLocation (which I can see @Agontuk / @iamjon has already done). ii) Leave the code as it was (calling requestLocation), and make it VERY clear in the documentation that if you enableHighAccuracy on iOS, it will likely take 10 seconds to return.

I am happy with i) - it has been working well for us for the last 2 years, but ii) would also be OK, and we could then update our application code.

NoahFace avatar Dec 12 '22 00:12 NoahFace

Any chance that @iamjon 's fix will be released some time soon? We can also confirm the issue with the current version of react-native-geolocation-service:

  • on iOS frequent timeout errors
  • no issues on Android

veb-ioki avatar Feb 08 '23 07:02 veb-ioki

~For us this is working fine again (on iOS & Android) even though the supposed fix was not merged. Can you confirm @NoahFace ?~

veb-ioki avatar Dec 06 '23 14:12 veb-ioki

I just edited my comment from Dec last year.

It still isn't working propperly for iOS. Any hope that there will be a new version with @iamjon 's PR included soon @Agontuk ??

veb-ioki avatar Apr 23 '24 14:04 veb-ioki