iOS 16 kills WKWebView instances unattached to a ViewController

In iOS 16 If you create a WKWebView instance in the app delegate and try to load something into it, it will crash. If I add the webview to the main viewcontroller but hide it off-screen, everything works fine. The problem is this webview should be headless and unattached because I'm only using it to scrape data and not displaying anything. Why waste the ram? iOS 16 betas did not have this issue.

[XPC] Handle connection with error: Connection interrupted

WebProcessProxy::didClose: (web process 0 crash)

WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash

ProcessAssertion::acquireSync Failed to acquire RBS assertion 'ConnectionTerminationWatchdog' for process with PID=0

[ServicesDaemonManager] interruptionHandler is called. -[FontServicesDaemonManager connection]_block_invoke

WebPageProxy::dispatchProcessDidTerminate: Not eagerly reloading the view because it is not currently visible

Replies

When you smash your left toe with a hammer remember you have nine more toes to go. What you're doing with the API is wrong and self-inflicted.

Try JSDom + JSContext instead of WKWebView for scraping.