Lyokone / flutterlocation

A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.
MIT License
1.08k stars 784 forks source link

[iOS] "UI unresponsiveness" warning when run on iOS 16 device #789

Open cbatson opened 1 year ago

cbatson commented 1 year ago

Description

Using package location version 4.4.0, there is a warning when run on an iOS 16 device:

[CoreLocation] This method can cause UI unresponsiveness if invoked on the main thread.
Instead, consider waiting for the `-locationManagerDidChangeAuthorization:` callback
and checking `authorizationStatus` first.

So far it appears the location service is still working, although a warning about UI unresponsiveness is quite disconcerting.

Expected behavior

No warnings when run.

Steps To Reproduce

  1. Run an app using package location version 4.4.0 on a device running iOS 16.

Tested on:

vAugagneur commented 1 year ago

+1

abdalmonem commented 1 year ago

same here

eliamirafiori commented 1 year ago

Until there are no updates you can add this to the Podfile to suppress all the warnings:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES"
    end
  end
end
abdalmonem commented 1 year ago

Until there are no updates you can add this to the Podfile to suppress all the warnings:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = "YES"
    end
  end
end

i do , but still same warning appear , and location didn't detected [CoreLocation] This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the-locationManagerDidChangeAuthorization:callback and checkingauthorizationStatusfirst.

luvishq commented 1 year ago

Any updates on this ?

DevTiago commented 1 year ago

+1 Im my case, the location never been updated. It detects location change but returns always the same coordinates.

elninho22 commented 1 year ago

+1

temos uma previsao de solução o impacto é gigantesco.

we have a forecast for a solution the impact is gigantic.

elninho22 commented 1 year ago

Has anyone managed to solve this problem?

I've tried several solutions by searching google, stackoverflow, etc.

cbatson commented 1 year ago

To be clear, this issue is about the presence of a warning that should ultimately be dealt with, but in and of itself does not affect functionality (at least as far as I've seen).

If you're seeing this warning and also having difficulty with the functionality of location services, I suggest you keep digging, as the issue you're experiencing could very well be something entirely different and unrelated.

If you find or have evidence that an issue with functionality is causally related to the warning, please bring that up in a comment on this issue and/or open a new issue.

wildsurfer commented 1 year ago

I faced the same problem

Hichemhino commented 1 year ago

for the people that can't update the location, try this solution : await Location().onLocationChanged.first => will return the first position

dgmmarin commented 1 year ago

Any updates on this bug?

vinodlee commented 11 months ago

Any Update on this bug?

vinodlee commented 11 months ago

I got this error

This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first.

dgmmarin commented 11 months ago

Just tried a quick fix in Xcode before building the archive and it works. Follow the path where the purple error shows, generally where you call if (![CLLocationManager locationServicesEnabled]) and wrap it with :

dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ //Background Thread if (![CLLocationManager locationServicesEnabled]) { result([FlutterError errorWithCode:@"SERVICE_STATUS_DISABLED" message:@"Failed to get location. Location services disabled" details:nil]); return; } });

dispatch_async does not use the main thread. Doing this i managed to avoid UI Unresponsiveness.

jocabedRios commented 1 month ago

Hi! Anybody has an update? I used this https://github.com/Lyokone/flutterlocation/issues/789#issuecomment-1665216167 and I don't get any warning but my app get stuck.

dgmmarin commented 1 month ago

Hi! Anybody has an update? I used this #789 (comment) and I don't get any warning but my app get stuck.

Have you wrapped in all places where location is called? In my case there were 2 places, the one that is in the example and another one.