Reputation: 2468
I am currently building an iOS 10 Swift (for all intended purposes insert 8/9 here) app, which is extensively using WebKit's WKWebViews. I want to be able to fire up and keep track of multiple WKWebViews in the same ViewController (and sometimes even show multiple WKWebViews on the same screen) Right now I have a pretty simple function, which initialises the WkWebView and opens a URL based on the user's input as shown in Apple's documentation. And if I were to use the function again, it would initialise a new WKWebView with the new URL.
How can I track the single WKWebView threads? I want to have a list of all running WKWebViews so I can close them one by one if necessary. Naturally I could use a dictionary for my function as a sort of log for the open URLs but I want to have a grip on the threads as well (keeping track of memory warnings etc.)
PS I tried looking at the current threads in Xcode but I cannot see the single WKWebView threads in the Debug navigator.
Upvotes: 4
Views: 1228
Reputation: 2468
I have finally found some info about the elusive memory accounting of WKWebViews! The WKWebViews are not shown in the process tree of an app and so they cannot be seen in the Debug Navigator. Furthermore if an app using WKWebViews runs out of memory it shouldn't crash but it might result into a blank WKWebView.
More info can be found here: https://forums.developer.apple.com/thread/21956
And a second source: https://www.hackingwithswift.com/example-code/wkwebview/whats-the-difference-between-uiwebview-and-wkwebview
I personally find this troubling because it's more or less impossible to make any kind of optimisations for power consumption etc. On the other hand it helps because we can use native JavaScript acceleration - we just can't have it all I guess.
Upvotes: 1