-
Notifications
You must be signed in to change notification settings - Fork 664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS 16 CDVLocation.m throwing UI unresponsiveness warning in XCode - causing app to crash. #257
Comments
Also on CDVLocation.m, XCode 14 is now throwing Alerts on line #216 #216 I think should be: |
Has anyone found a fork out there with this fix or have any idea how to solve this? I have an app update being blocked from release at Apple because of this. I hope I don't have to do a full re-write... |
Not aware of any forks but a rewrite shouldn't be necessary. The warning is caused by some APIs that checks states on the location manager, which may block for a long time so it isn't desirable to call on the main thread. If it does block for a significant of time, it will make hte app unresponsive since it will block UI updates. So the solution is to not call on those checks on the main thread. However it's not as trivial as simply wrapping the code in a background block. The CLLocationManager instance is only safe to use on the thread/dispatch queue it was created in. So the solution is probably to create a dispatch queue for geolocation usage and have the CLLocationManager initialized in that queue, as well as any cordova calls to switch to that queue when performing location manager calls. And of course to return back to the main queue when calling back to the webview. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
When I opened this nearly two years ago I see that @kumo01GitHub has committed a fix for this...however, upon further inspection it appears the fix is simply to remove the warning as opposed to actually fixing the issue. Is this the case? If it is a fix, when can it be fully committed....if its just removing the warning without a true fix what is the risk here? Last, trying to analyze the original issue, and I am wondering what is considered "the main thread?" I keep thinking this is an error specifically from within |
The main thread refers to the main application event loop. This is often (and is the case for iOS apps) tied to the UI, so sometimes the main thread is also called the UI thread. Blocking the main thread will cause the UI to become unresponsive, and make the app feel laggy, or choppy. The geolocation API being used is being called on the main thread, and that API uses networking/gps hardware that can take a long time to complete, and has a risk of blocking the UI from updating, hence the warning. Additionally, iOS has a "watchdog" that monitors app's main threads and if they are blocked for 3-5 seconds ios can kill the app, causing an app crash, which is another reason why blocking the main thread is dangerous. I just had a glance at #283 and I think it's mislabeled. #283 wouldn't address this issue. It's changing code to explicitly reference He has a different commit that looks like it would solve this issue by moving the offending code off the main thread, but I'm not sure if there is a PR created. |
Ok, so to clarify, there is nothing I can specifically do in my App that would eliminate this error? It really is an issue inside of This entire upgrade effort and see the above error still happen triggered me into doing some extensive testing. My app requires GPS. When my app initializes I call a function every 1 second for the first 15 seconds, then every 3 seconds up to the first 45 seconds and then every 10 seconds after that. GPS usually takes about 30 to 45 seconds to truly get the most accurate user location. so for the first 45 seconds after app starts I am aggressively trying to get the users exact location.....then after the first 45 seconds I back off the aggressive ness and update the users position (in the app) about every 10 seconds. I am using this function to do this:
getPosition() calls the geolocation plugin with: Everytime getCurrentPosition() is called Xcode tracks the error. Is there a better method to track the user location changes other than having to call getCurrentPosition() every 10 seconds? I would really like to get rid of this error I am getting in Xcode/iOS and am wondering if a better method would help me eliminate the error. |
uhhh....just looked at the plugin again, the watchPosition() would be what I need for a better method. I honestly have no idea how I over looked this. My only explanation was in years past I couldn't get something to work and abandoned watchPosition() for my own Egg on my face. :-( |
I'm sorry that #283 is only address this part:
This commit might help this issue and it looks no problem with simple operation check but as comment on code, I couldn't resolve below. So, I didn't make PR yet:
|
Bug Report
A new feature in Xcode 14 is displaying purple warnings about UI Unresponsiveness coming from CDVLocation.m#L89 - this issue seems specific to iOS 16x too. Its a part of the
isLocationServicesEnabled
function.This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the
-locationManagerDidChangeAuthorization:callback and checking
authorizationStatusfirst.
The warning gets thrown about 50 times too (not certain why though). I and others (on different forums) are experience app freeze/crashes with some getting apps rejected from app store.
Problem
iOS 16 apparently has changed behavior regarding location permission checks - the specific code commented with
iOS 4.x
- so it looks like a fix for iOS 4 and has worked all the way through iOS 15 is now causing issues.What is expected to happen?
Work cleanly without throwing warnings.
What does actually happen?
Throws the above warning.
Environment, Platform, Device
Mac 13.2.1 Ventura
Xcode 14.2
Version information
Cordova 11
cordova-ios: 6.2.0
iOS: 16.x
Checklist
The text was updated successfully, but these errors were encountered: