how to prevernt "webViewWebContentProcessDidTerminate:"happen?

we have wkwebView page which use js bridge to launch camera to take photos. some times the "webViewWebContentProcessDidTerminate:" get called ,we have to relaod the page(it don't,the page will go blankl or unresponsive),but then the user content was lost. By my experience,this is associate with memory。at the moment we take photo,the total memory useage get high more the 10~20M high. but when I don't l;aucn the camera,it's worked well. i have question about this.

  1. how to reduce the memory useage by camera at the moment?I has already add @autoreleasepool to the take photo finish event,it's get down when finished, it has a peak but I want it keep steady。

  2. as we know the wkwebview work in independent process,how the memory useage can affect the wk process?

  3. any other way to prevent this? please help!

Hello, "webViewWebContentProcessDidTerminate:" call is not always related to memory usage and I'd first try to detect more or less reliable steps to reproduce the issue and then implement "- (void)_webView:(WKWebView *)webView webContentProcessDidTerminateWithReason:(int)reason" instead of "webViewWebContentProcessDidTerminate:". This is a private method and you shoundn't be using it in release apps since it wasn't designed for any WKWebView app. It is documented in WebKit's Github repo, look for WKNavigationDelegatePrivate.h file. The reason why you may want to use is that it specifies reason of the WebKit termination, and once you confirm that this is memory crash, you will have zero in reason variable, then you should proceed with attempts to reduce memory usage, but if it is just regular crash, reason will be 3, then you need to find WebKit's crash log, and from that point continue your investigation, depending on call stack.

how to prevernt "webViewWebContentProcessDidTerminate:"happen?
 
 
Q