iOS中WKWebView加载HTML反复出现113服务错误求助
Hey there, I’ve helped a lot of developers work through this exact WKWebView error—those repetitive logs can be frustrating, but let’s break down the most common fixes that usually resolve it:
1. Double-Check WKWebView Lifecycle & Memory Management
This error often pops up if your WKWebView instance gets released prematurely. Make sure:
- Your
_articleWebViewis a strongly referenced property (not weak) in your view controller. ARC might clean it up before the WebContent service can connect if it’s weakly held. - You’re adding the web view to a parent view (your code snippet cuts off, but don’t forget
[_mainView.containterViiew addSubview:_articleWebView];—if it’s not in the view hierarchy, the service can’t initialize properly). - You’re not accidentally setting
_articleWebView = nilsomewhere before the web view finishes loading.
2. Simplify Your WKWebViewConfiguration
Custom configurations can sometimes interfere with the WebContent service startup. Try testing with a default configuration first:
// Remove any custom settings temporarily WKWebViewConfiguration *conf = [[WKWebViewConfiguration alloc] init]; // Skip adding preferences or user scripts for now _articleWebView = [[WKWebView alloc] initWithFrame:_mainView.containterViiew.bounds configuration:conf];
If the error goes away, gradually reintroduce your custom settings to identify which one is causing the conflict.
3. Rule Out Environment & Cache Issues
- Restart your device/simulator: Sometimes stuck WebContent processes from previous app runs can cause this. A fresh restart clears those lingering services.
- Reinstall your app: Corrupted cache files or leftover WebKit data might be preventing the service from launching. Delete the app, clean your build folder (
Cmd+Shift+Kin Xcode), and rebuild. - Test on both simulator and real device: This error can be simulator-specific in some iOS versions—if it only shows up in the simulator, it might be a platform bug that’s harmless (though still annoying).
4. Validate Your Loaded Content
If the error only happens when loading your specific HTML (not a test page like https://apple.com), your content might be triggering a WebContent crash:
- Load a simple static HTML string first to test:
NSString *testHTML = @"<html><body><h1>Test Page</h1></body></html>"; [_articleWebView loadHTMLString:testHTML baseURL:nil]; - Check your HTML for invalid syntax, broken JS/CSS references, or third-party scripts that might be crashing the WebContent process.
5. Check iOS Version Compatibility
Certain iOS beta versions or older releases (like early iOS 13 builds) had known bugs with this exact error. If you’re not on the latest stable iOS version, update your device/Xcode simulator to the newest release—Apple often patches these WebKit service issues.
Quick Note
In some cases, this error is just noisy logging and doesn’t actually break functionality. If your web view loads and works fine despite the logs, you might choose to ignore it (though it’s still best to resolve the root cause if possible).
内容的提问来源于stack exchange,提问作者Siju Satheesachandran

