"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

Same issue here. When is this fix expected?

Went through the whole thread but didn't see any solutions to this. Our app displays a VC which has a WKWebView in it. It's still working and displaying the same content without a problem but that warning is a bit annoying and I'm not sure if it will cause issues on other iOS devices or not

Same here Xcode Version 14.0 (14A309), app runs fine, will ignore warning. Would be nice to generally be allowed to let wkwebview live in background-thread.

Same here Xcode Version 14.0.1 (14A400), app runs fine, but receiving that warning in AppDelegate.

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {....}
  • 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

First of all, this problem occurs with apps that use the admob library.

Among the apps I sell, there is a paid app with a different target (same code) in the same project. When I build this paid app in my project, I don't see this warning.

My paid app uses "Other Swifts Flag" to not include the admob library in the code from the build generation, and the admob library is not included in the app.

I contacted Admob and got a reply.

Admob is also aware of this issue. Admob believes it's a bug by Apple, and Apple is also aware of this bug. Maybe it will be improved in the next Xcode or iOS update.

My guess is that when using WKWebView in Admob, you get such a warning message.

  • No, mI add is not using admob library and get the same error. So I think is something on Apple side.

Add a Comment

FB11618231

  • Thank you!

Add a Comment

Seems like a Bug in WebKit for me. I don't use admob and WKWebview ist not on the first ViewController. The App can be used without the warning until a WKWebView is called for the first time. Then the warning appears.

So these lines of the thread seems the important one:

I have written a simple View to help anyone trying to isolate this issue that I discovered while trying to find the source of this warning. In my instance, I am using WKWebView to load specific sites that seems to trigger the warning when load(_ request: URLRequest) method is called.

import SwiftUI
import WebKit

struct WebView: UIViewRepresentable {
    typealias UIViewType = WKWebView

    let webView: WKWebView

    func makeUIView(context: Context) -> WKWebView {
        return self.webView
    }

    func updateUIView(_ uiView: WKWebView, context: Context) {
    }
}

struct TestView: View {
    let webView = WKWebView(frame: .zero)

    var body: some View {
        ZStack {
            WebView(webView: self.webView)
            Button("Test", action: {
                Task.detached(priority: .background) {
                    await self.webView.load(URLRequest(url: URL(string: "https://www.apple.com")!))
                }
            })
        }
    }
}

Even when attaching the load(_ request: URLRequest) method to a background thread seems to cause the warning.

I am not expert in SwiftUI or the new Concurrency methods, but is there a 'proper' why that this method is supposed to be called off the main thread?

I am getting This method should not be called on the main thread as it may lead to UI unresponsiveness in Xcode 14 when running on iOS 16. I have submitted the bug report and here is my FB number: FB11655869

  • Thank you for filing FB11655869!

Add a Comment

Problem in appdelegate class thread

when UiactivityController shows,Xcode says This method should not be called on the main thread as it may lead to UI unresponsiveness. in appdelegate class.

DispatchQueue.global.async. DispatchQueue.global(qos: .background).async. don't help.

what is this?

  • @Vardan4455 The fact that appDelegate is shown does not mean problem originates here. In fact, it comes from some webKit call.

Add a Comment

Bueller? Bueller? No updates after 2 weeks? Issue still exists.

  • Please see the previous information I shared, and request for you to open a report in Feedback Assistant and share the FB number here.

Add a Comment

This warning is unnecessary and shouldn't show for apps that are otherwise working fine. Not everything has to be optimised perfectly to run in the background if it's responsive enough - please remove the warning in the next version of Xcode Apple.

  • It would be most helpful if you could file a bug report and then post the FB number here with the backtrace triggering the runtime issue diagnostic message. Please see my prior answer for context.

Add a Comment

Same problem came out of nowhere, the app still work great. After I updated macOS to Ventura 13.0 and Xcode I get this warning.

"This method should not be called on the main thread as it may lead to UI unresponsiveness."

Weird that Xcode does not propose a solution. I suspect it is just an Xcode bug.

  • It would be most helpful if you could file a bug report and then post the FB number here with the backtrace triggering the runtime issue diagnostic message. Please see my prior answer for context.

Add a Comment

Same thing here, when I comment out WKWebView.load() the warning goes away. But when I try to set the loading to a background thread, it throws a thread error and gives this warning: "WKWebView.load(_:) must be used from main thread only"

So I can't have it on the main thread, but it can only be on the main thread...

FB11742846

Add a Comment