I've seen several cases where WebKit raises an exception:
-[NSCFArray insertObject:atIndex:]: attempt to insert nil
when my code calls [[[webView mainFrame] dataSource] webArchive]. I've been able to reproduce this only rarely on my Mac, but I have a customer for whom it happens 100% of the time, no matter the page.
As far as I can tell, the exception is being raised in -[WebDataSource subresources]. It looks like the WebResource that's being created in the loop is returning nil from its -init method. While there may be an interesting and significant reason for that, I suggest that -subresources refrain from adding nil objects to the array so that at least a partial Web archive can be returned.
Does your customer have any third-party "extensions" (haxies, input managers, etc.) installed for Safari?
Could you have the customer recreate the crash and post a crash log to this bug? If you would prefer not to post a crash log of your application here, please create a bug using <https://bugreport.apple.com/> and report the 7-digit bug number here.
It's not crashing for the customer, just raising an exception that's caught in my code.
(In reply to comment #4)
> It's not crashing for the customer, just raising an exception that's caught in
> my code.
Is there any way you could provide a stack trace when the exception is caught? Can you provide a reproducible test case using a local copy of the customer's web page?
BTW, what revision(s) of WebKit are you using? Does this work on a nightly WebKit build?
After re-reading the description, this sounds related to Bug 22466. I think the code in WebKit -[WebDataSource subresources] has moved to DocumentLoader::subresources() in tip-of-tree (ToT) WebKit, though.
One of the problem Web pages was:
I am no longer able to reproduce the problem using the WebKit from Safari 3.2.1.
(In reply to comment #6)
> One of the problem Web pages was:
> I am no longer able to reproduce the problem using the WebKit from Safari
Can this bug be closed then?
See also Bug 17151.
Closing per Comment #8.