Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing a custom NSURLProtocol on iOS for file:// URLs causes "Frame load interrupted" error
    primarykey
    data
    text
    <p>I want to load changing files into a UIWebView, and I want them to be loaded under the file:// scheme so I can include other file:// resources (such as html5 video elements) in my page. To do this I implement my own NSURLProtocol and override the loading of a subset of file:// URLs.</p> <p>my <code>startLoading</code> method looks something like:</p> <pre><code>- (void) startLoading { ... data is populated ... [protocolClient URLProtocol:self didLoadData:data]; [protocolClient URLProtocolDidFinishLoading:self]; } </code></pre> <p>This works fine on iOS4/5 but on iOS 6 beta 4 I get the following error:</p> <pre><code>2012-08-21 16:06:07.236 TemplateApp[57283:1d403] 57283: CFNetwork internal error (0xc01a:/SourceCache/CFNetwork_Sim/CFNetwork-606/Connection/URLConnectionClient.cpp:2341) /SourceCache/WebCore_Sim/WebCore-1634/wak/WKView.mm:385 void WKViewAddSubview(WKViewRef, WKViewRef): invalid parameter 2012-08-21 16:06:07.272 TemplateApp[57283:1e603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSSetM addObject:]: object cannot be nil' *** First throw call stack: (0x29d0552 0x2733e7e 0x2a5dc08 0x69c6c1e 0x69c4c88 0x69c543b 0x5b40dbd 0x5b40f0f 0x5b3c240 0x5ff8060 0x5ff75d1 0x5eb8d08 0x65a4fb2 0x678486f 0x677fa3d 0x7b3ab1 0x7b2d63 0x7f0e5a 0x2972ebd 0x7f14dc 0x7f1455 0x6db410 0x29544ff 0x2953f2f 0x2976cf4 0x2976504 0x29763db 0x69d0530 0x907caed9 0x907ce6de) libc++abi.dylib: terminate called throwing an exception </code></pre> <p>I resolved this by adding a <code>didReceiveResponse</code> call to my <code>startLoading</code> method as follows:</p> <pre><code>- (void) startLoading { ... data is populated ... [protocolClient URLProtocol:self didReceiveResponse:[[NSURLResponse alloc] init] cacheStoragePolicy:NSURLCacheStorageAllowed] [protocolClient URLProtocol:self didLoadData:data]; [protocolClient URLProtocolDidFinishLoading:self]; } </code></pre> <p>However now on iOS 5 and 6 I get the following error when trying to load a page:</p> <pre><code>Webview error: Error Domain=WebKitErrorDomain Code=102 "Frame load interrupted" UserInfo=0x9d4c0a0 {NSErrorFailingURLKey=file:///src/index.html, NSErrorFailingURLStringKey=file:///src/index.html, NSLocalizedDescription=Frame load interrupted} </code></pre> <p>I have tried various different NSURLResponse objects in the <code>didReceiveResponse</code> method but none of them allowed the WebView to load the page. Using a URL scheme other than file:// also works but then I cannot use file:// paths for embedded resources such as HTML5 video.</p> <p>Is there a way for me to load dynamic content for a specific file:// URL into a UIWebView which works on iOS 6 beta 4?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload