WKWebView freezes when I start the Embassy http server
josh83abc opened this issue · comments
Hi guys!
I'm an experienced developer but a beginner with Swift and iOS, so your help will be very valuable.
My iOS app is based on a WKWebView loading some HTML (hybrid app).
Since the WKWebView cant access to local files, I wanted to run a HTTP server on the iOS device and then use it from inside the WKWebView.
However, when I start the Embassy server like in your example, my WKWebView becomes unresponsive and completely frozen. If I start a safari outside the app, I do see that the HTTP server is working.
I also do see that it is the line "loop.runForever()" which freezes the webview.
How can I fix that? Maybe I missed something :)
Thanks a lot!!
Josh
Don't use runForever
in UI thread. You need DispatchQueue.global(qos: .background).async