1

I've built a custom NSURLProtocol which is used by a WebView whilst it browses. But at seemingly random times (between a 20 seconds or a few minutes into browsing) I am getting an EXC_BREAKPOINT and the app stops running in my NSURLProtocol.

The relevant part of my NSURLProtocol is below, it's the last line which is showing the EXC_BREAKPOINT

self.mutableData = NSMutableData(data: data!)  
self.response = response  
self.client?.URLProtocol(self, didReceiveResponse: response!, cacheStoragePolicy: NSURLCacheStoragePolicy.Allowed)  
self.client?.URLProtocol(self, didLoadData: data!)  
self.client?.URLProtocolDidFinishLoading(self)

The Xcode error is visible below: enter image description here

I'm totally bamboozled on this one. Does anyone have an idea what might be causing this, and how to fix it?

Thank you!

Sam

Sam Heather
  • 1,493
  • 3
  • 19
  • 42

1 Answers1

0

There's not enough context for me to fully understand the code here, much less guess what's wrong, but basically what's happening is that there's a lock (mutex) that has been deallocated, but is still being used somewhere down in the NSURL* stack.

This probably points to something not getting retained properly, but it is anybody's guess what or where. It might even be that your protocol is not getting retained properly, in which case you might be able to fix it by assigning your protocol object to a property on itself until after you call your last delegate method, then nulling it out.

With that said, there's reason to believe that this is a bug in the OS itself, so while you try to work around it, you should also file a bug. It will get duped to the other dozen or so bugs from other people who have asked this same question both here and on the Apple developer forums. :-)

dgatwood
  • 10,129
  • 1
  • 28
  • 49