63

When loading the URL in WKWebView, it leads to a security warning and later app gets crashes.

Warning in UIApplicationMain -

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

Security Warning in WKWebview

How can I resolve this issue?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
PrasathBabu
  • 4,716
  • 4
  • 19
  • 35
  • 4
    got same issue, seems it apple bug – GalaevAlexey Oct 13 '22 at 03:18
  • same exact issue, anyone would be able to solve this? Putting web views certificate validation on DispatchQueue.global(qos: .background).async { } doesn't help. – Async- Nov 03 '22 at 09:55
  • same issue as I wrapped a WKWebView in `UIViewRepresentable`. I've also changed the code running by `WKNavigationDelegate`calls to dispatch on main. Still getting this. – zumzum Nov 21 '22 at 20:33

2 Answers2

34

Good in-depth reply from an Apple employee on the forums.

The poor interaction between WKWebView, Security framework, and this Xcode feature is a known issue (r. 94019453). We plan to address it at some point but I don’t have any info to share as to when that’ll happen.

Spevacus
  • 584
  • 2
  • 13
  • 23
Grant Kamin
  • 1,230
  • 11
  • 11
15

Apparently, it is either an Xcode bug or an unnecessary "perfect optimization" notification.

As I'm writing, there isn't any reported solution on the Apple developer website.

You can see a good discussion on UI unresponsiveness" warning on @main.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Filipe Canzi
  • 150
  • 5