I wrote a huge iPad app 2 years ago and now I'm getting back to it and upgrading it to iOS5. Its a bit messy as it was my first large iPad app.
Its has a "sync" step that may last for several minutes and these are a bunch of asynchronous method calls that go and fetch JSON from a url and put them into core data. Fairly often, the app will freeze (UI is unresponsive).
What are some good techniques to track down this freezing? The debugger isn't that helpful as unless the code is running on the main thread, you have no useable stack trace. The app often does not recover either which suggests some sort of dead lock situation.
Here is one particular example that might help:
I paused the execution once I verified that it was frozen. It seems to freeze on the same line every time - a simple assignment. What is going on here? Its so frustrating.
Is this core data access that is causing this? Any pointers would be greatly appreciated.
EDIT 29-JUNE-2012
Click here to see the source of the class that does all the Create/Update/Deleting of Core data objects. I just need to stop the freezing/crashing in this app. I know its a mess, it makes me cringe too. I wrote this 2 years ago with hardly any knowledge of objective-c. I should re-write it but I have to get this working and out of my head in 2 days. Could anyone give me pointers on approaches to get this thread-safe quickly? Could I wrap each method that updates NSManagedObjectContext in grand central dispatch block code?
It is indeed possible that Core Data (in combination with multithreading) is the cause of your troubles - I experienced similar problems.
Here's an excellent article on this topic: Core Data and threads, without the headache
I also see a call to performSelector:
in your stack trace. You might want to consider to use Grand Central Dispatch, although that might be a lot to rewrite in your case.
As for your your actual question (tracking down deadlocks), I'd suggest using Instruments as well. Also, look at the status of the other threads.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With