"UI unresponsiveness" warning on @main

  • ">

  • Sama here, Xcode 14.2.

Add a Comment

Apple Recommended

  • I've replied back below. please note

  • I updated to OS 13.0.1 and Xcode to 14.1. My app now reports this same error "This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the -locationManagerDidChangeAuthorization: callback and checking authorizationStatus first." and traces it to this bit of code:

    if CLLocationManager.locationServicesEnabled(). So, I implemented the suggested fix, but the complier says that authorizationStatus was deprecated in iOS 14.0

  • this is not helpful at all

Add a Comment

Replies

I am facing the same issue while loading a web Page. Before that, I met the same problem when I was using a library to embed youtube videos and that library also used web view to load youtube videos. it has no problem if we load a web page only a single time but the simulator hangs if we load the web page multiple times. I am afraid it can cause my app to crash.

This also seems to happen when making a SwiftUI application scriptable (integrating AppleScript responders like NSScriptCommand)

This does not happen directly when starting the app, but only after issuing it an AppleScript command. So I'm not entirely sure if this warning is right. Responding to AppleScript is blocking the main thread, but I don't see if there's another way as it seems to be all Apple internals.

  • I encountered exactly the same behavior in all my scriptable projects regardless of Storyboard, XIB, SwiftUI or completely faceless application.

  • I see a similar stack trace when loading a sign-in page into a webview from the first screen of our app. The webview is loading an Azure ADB2C sign-in screen for SSO.

Add a Comment

I have 2 apps practically identicals (ver. Pro & lite) and I've the issue only in one.... The difference is that one have the googleAds and not the other. Is possible that this "error" be for this library.

What is the status of this bug? I am also having this issue and it has been 6 months of being asked, did you guys come up with any solution?

As I can see, it happens only in Simulator by using Web View. Tested on my Iphone IOS 15.7 without warnings.

Same here - This method should not be called on the main thread as it may lead to UI unresponsiveness. Xcode 14.2, target iOS 16.0. Cause: Google Ad Mob.

POSSIBLE LEAD ON WHAT'S CAUSING THE ISSUE/POSSIBLE SOLUTION TO LOOK INTO

this has happened me just now too. There was no such error until the last ten minutes and I've been running the app all day with no queries that would cause this.

The errors give no indication of what's wrong, but when I removed the last thing I added before the issues arose it resolved. I had created a String extension as per below and then tried to use it. When I removed the extension the issues disappeared again.

Probably not the exact same thing for everyone, but if you have a similar extension changing an Apple type then it looks like certain methods that take time to go do something shouldn't be used because it would delay the main thread - in my case i was trying to check if a string could be opened as a url. I'm guessing here and don't fully understand but least the issues seem to disappear. Wish there was more info in the warning itself to help us identify why!

//MARK: - Extension to check if string is a valid url

extension String {
    var isValidURL: Bool {

        if let url = NSURL(string: self) {
            return UIApplication.shared.canOpenURL(url as URL)
        }
        else if self.contains("https") == false &&  self.contains("www.") == true { //in case user didn't put https, check if added that
            let newstring = "https://\(self)"
            if let url = NSURL(string: newstring) {
                return UIApplication.shared.canOpenURL(url as URL)
            }
            else {
                return false
            }
        }
        else {
            return false
        }
    }
}

Having the same issue with an app that was working fine a few months ago, it went dormant, and now trying to do some more work on it. The app will do all sorts of async things, but I'm getting this right on the main thread as shown by the image below. The code the warning shows up on is below. It points to the line with "@main". And the stack trace is also just there (shows boilerplate code).

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Now, because a previous poster mentioned AdMob, I commented that out and the warning went away. I fixed it by just moving the AdMob init code into an async function, and that took care of the warning.

BUT JESUS! How about generating a warning that makes sense? Point to the line with the admob code!

  • Actually, I take it back about fixing it. If your issue is related to google admob, check out this thread: https://groups.google.com/g/google-admob-ads-sdk/c/QQLDBQlO340?pli=1

    Google support is saying "bug in apple stuff", but others are questioning that conclusion.

Add a Comment

You all can verify for yourselves, but Xcode 14.3 fixed this issue for me!

  • same here, debug console still showing the warning message(s) though when running the app but at least the purple warnings are gone which is at least something

Add a Comment

I'm seeing the same thing for a few recent Xcode releases. Happens when calling MTRegisterProfessionalVideoWorkflowFormatReaders(); inside AppDelegate init.

Filed as FB12137794

I get the same warning in XCode14.3. The warning is pointing at an Apple framework, AppleScriptObjC.framework.

@NSApplicationMain 
class AppDelegate: NSObject, NSApplicationDelegate 
{ 
   override init() 
   { 
      Bundle.main.loadAppleScriptObjectiveCScripts() // warning here
      ... 
   } 
   ... 
}

Seems like complain/issues only, no responses at all. Is this even usefull?