<div dir="ltr">Hello,<div><br></div><div>I&#39;d like to ask your for advice about implementation of a custom networking layer with WKWebView on iOS.</div><div><br></div><div>Our current solution is based on NSURLProtocol, and the issues we had with it in 2014 are unresolved:</div><div><a href="https://bugs.webkit.org/show_bug.cgi?id=137302">https://bugs.webkit.org/show_bug.cgi?id=137302</a><br></div><div><a href="https://bugs.webkit.org/show_bug.cgi?id=138131">https://bugs.webkit.org/show_bug.cgi?id=138131</a><br></div><div><br></div><div>It was kind of a shoehorn hack, and so it was rejected by Benjamin Poulain and Alexey Proskuryakov among other reviewers.</div><div><br></div><div>Now I&#39;m again looking for a better solution.</div><div><div>I&#39;d really like to discuss it with somebody responsible, reach common understanding and agreement, and attack this problem.</div></div><div><br></div><div>There&#39;s currently 2 solutions I&#39;m weighting:</div><div><ol><li>Pass and use NetworkProcessCreationParameters.httpProxy to NSURLSessionConfiguration (in NetworkSession and maybe other places).</li><li>Add a new mode to the NetworkProcess, which would do all networking in UIProcess (instead of spawning a new process). A mode would be optional and controlled with some configuration setting (or NSUserDefaults).</li></ol><div>The httpProxy solution is easy to implement and would look clean design-wise. It would let us spawn an HTTP proxy on localhost and filter the traffic there. There might be some complications, because it&#39;s not fully transparent to the client side. For example HTTPS will have issues. All in all this could be a fine short-term solution.<br></div></div><div><br></div><div>The UIProcess solution is harder to implement, and it will affect more code. It is somewhat controversial. One of the reasons of splitting out a NetworkProcess was to have it respawn after crashes. Nevertheless we can take this risk, because in practice we know that most of the crashes happen in the WebProcess parts. I don&#39;t see any other significant downsides of having the UIProcess handling networking. To me this seems like a better choice than httpProxy, because this way we avoid unnecessary data passing back and forth. We get more control, because it&#39;s transparent. In addition it can simplify the NetworkProcess debugging.</div><div><br></div><div>--<br></div><div>With best regards,</div><div>Daniel Lazarenko</div><div><br></div></div>