Recently when I was doing some performance fixes for an iOS app I am working on, I came across a strange issue.  The app UI would freeze indefinitely without causing a crash or hitting a breakpoint. This freeze was intermittent, which made things difficult. Initially I suspected a deadlock in some new code, but I had not introduced any explicit @synchronized or semaphore wait statements in the code <which generally cause deadlocks>. All I had done is moved JSON response parsing code to a shared background queue.

On the debugger, hitting the pause button showed me that the execution was stuck in [pmutex wait] method. Quick googling of this gave me the answer I was looking for.

core data is not thread safe

core data is not thread safe !

Cause

What had happened was that I was using Core Data abstraction for database storage and I had made a singleton class for all database methods (seems like a bad idea now). Continue reading “iOS/Cocoa : Resolving deadlock caused by core data multi threading” »

Incoming search terms: