"UI unresponsiveness" warning on @main

I'm seeing a runtime warning in Xcode 14 Beta 5 that says "This method should not be called on the main thread as it may lead to UI unresponsiveness."

This is happening on the @main entry point of my app. See below:

The warning shown gives me no insight into what's actually going wrong. I think it may be due to some Core Location code that runs when the app first opens, but is there a way for me to get some more insight into what's causing this?

Or is this possibly an Xcode 14/iOS 16 bug, and this is not an issue to worry about? I'm not getting any warnings on Xcode 13/iOS 15.

Answered by DTS Engineer in 730526022

The purple warning is calling attention to a runtime issue that may impact the performance of your app. In general, you should resolve these issues when they are in your code, by moving the code off the main thread. When you receive one of these runtime performance issues, you can expand the backtrace in the Issue Navigator, available through the View > Navigators > Issues menu, to see where the issue is located.

If you find the issue is pointing at an Apple framework, please use Feedback Assistant to open a bug report to let us know, and include the complete backtrace shown in the issue navigator. You can post the FB numbers to this thread for visibility. Further, if you can't identify where the issue is coming from, as the backtrace points to your main function, please also let us know, including the provided backtrace.

If you find the runtime issue is resulting from an Apple API call used in a sub-optimal way within a third-party library that your app uses, please open a bug report with the library vendor.

I get the same warning in XCode14 Beta 5 in my objective C main() when it calls UIApplicationMain(argc, argv, nil, nil); (See below)

I use a WKWebView to allow user to login.

For me it seems to happen if I display a WkWebView when I start my Aop. If I run and don't need to display the WkWebView (Ie I already have login details) then I don't seem to get the warning...

int main(int argc, char *argv[]) {

    @autoreleasepool {

        int retVal = UIApplicationMain(argc, argv, nil, nil);

        return retVal;

    }

}

All a bit worrying but I have no clue what it means.

Happening to me too. Someone please solve this

I also encountered the same phenomenon.

However, depending on the loading URL, this message may or may not be displayed.

I'm not quite sure what the difference is.

When this message was not displayed, the following message was displayed.

Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Xcode Version 14.0 beta 6 (14A5294g)

iOS16.0 beta 8

iPhone SE 2generation

Any solutions on this? Someone please solve this.

Xcode 14 Beta 5 iOS 16.0

Same here!

Same here on Xcode 14 beta 6 / iOS 16.0 beta 8. Would love to know if any updates.

same for me a warning error : This method should not be called on the main thread as it may lead to UI unresponsiveness.

I'm experiencing the same thing with WkWebView (not in SwiftUI).

Xcode 14.0 beta 6 (14A5294g)

Same here with UIKit, AppDelegate and WKWebView. Points to class AppDelegate in the warning... no other information.

If you are continuing to see this when using Xcode 14 Release Candidate running an app on iOS 16 Release Candidate, please provide detailed specifics in a bug report., and then post the FB number here.

It was the same on iOS16RC&xcode14RC. Posted: FB 11480364

Yep WkWebView.load(URLRequest) in a UIKit app causes this issue for me in the Xcode 14 RC.

Same error using Xcode Version 14.0 (14A309), iOS16 on iPad. Using WkWebView with SwiftUI.

Same error for me happening

Facing the same issue, any solution or workaround?

10

Same here after update to Xcode 14.0 today

Same issue is there any Fix for this?

In my case, I spotted the error on line 2, in viewDidLoad (but same issue if put elsewhere like viewDidAppear):

1.         guard let url = URL(string: "https://google.com") else {return}
2.         myWebView.load(URLRequest(url: url))

Problem: load MUST run on main thread (dispatching to another queue causes run time crash) WKWebView.load(_:) must be used from main thread only

Dispatching to main.async, logically does not change anything. That occurs in Xcode 14 / iOS 16 simulator. Also occurs with Xcode 13.4.1 / iOS 16. No such error message in Xcode 13.4.1 / iOS 15.5 So that's a new warning in iOS 16. I read there is a solution by prelaoding, but did not test yet. https://coderwall.com/p/trjkcg/preloading-uiwebview-or-wkwebview-in-swift

It is just a warning, if it works OK on real app, I think we should just ignore it.

Same for me with WKWebView

Same issue. What is going on with Xcode?

Same issue. How to fix it ?

I am seeing the problem with the simulator..but not when running on a real iPad..

Simulator Version 14.0 (986.3) SimulatorKit 624 CoreSimulator 857.7

I have a SwiftUI App that displays an animated gif from a weather api, using UIViewRepresentable and WKWebView. I also get this warning. I'm using the Xcode RC. I've checked the preloading solution, but not sure how I can apply this to an App with SwiftUI lifecycle.

Same purple security warning in Xcode 14 (latest release) here. "This method should not be called on the main thread as it may lead to UI unresponsiveness."

In my case I've traced it to a WKWebView -> loadRequest:, i.e. called from my main ViewController's -> viewDidLoad:

i.e. I load a web view at app startup, as after launch/splash screen it's the first view user will see. I'm careful about accounting for network issues and will timeout (or not even try loading), display an alternative screen, etc. if there are network issues.

I'm going to assume someone on the Xcode team chose to add this warning in the event a developer doesn't account for slow loading or not loading at all an initial wkwebview when the app first launches?

Any other theories? Is it safe to ignore the warning?

same issue here

"UI unresponsiveness" warning on @main
 
 
Q