flutterlocation icon indicating copy to clipboard operation
flutterlocation copied to clipboard

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

Open cbatson opened this issue 2 years ago • 18 comments

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:

  • iOS 16 device

cbatson avatar Dec 24 '22 19:12 cbatson

+1

vAugagneur avatar Jan 06 '23 15:01 vAugagneur

same here

abdalmonem avatar Jan 17 '23 06:01 abdalmonem

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

eliamirafiori avatar Jan 17 '23 13:01 eliamirafiori

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.

abdalmonem avatar Jan 19 '23 07:01 abdalmonem

Any updates on this ?

luvishq avatar Jan 29 '23 05:01 luvishq

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

DevTiago avatar Feb 14 '23 17:02 DevTiago

+1

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

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

elninho22 avatar Feb 23 '23 01:02 elninho22

Has anyone managed to solve this problem?

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

elninho22 avatar Mar 02 '23 17:03 elninho22

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.

cbatson avatar Mar 02 '23 17:03 cbatson

I faced the same problem

wildsurfer avatar Mar 19 '23 17:03 wildsurfer

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

Hichemhino avatar Mar 24 '23 16:03 Hichemhino

Any updates on this bug?

dgmmarin avatar Jul 06 '23 14:07 dgmmarin

Any Update on this bug?

vinodlee avatar Jul 18 '23 13:07 vinodlee

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.

vinodlee avatar Jul 18 '23 13:07 vinodlee

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.

dgmmarin avatar Aug 04 '23 08:08 dgmmarin

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.

jocabedRios avatar May 28 '24 15:05 jocabedRios

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.

dgmmarin avatar May 29 '24 13:05 dgmmarin