My app freezes but no error appears
I have similar case in my project and the reason was another developer who added setNeedsLayout()
inside method layoutSubviews()
and this make infinite loop and freeze the app.
Besides pausing and following the stacktrace I think as an additional thing to do, is to check in the code if there's any loop causing the app freezes.
I recently ran into a similar problem, but stack trace didn't help much, I figured out that I was having an eternal loop when calling a reloadData()
inside layoutsubviews method and that was causing a freeze with no errors and no help from instruments.
Top answer is correct. You can debug this with "Pause" option. Most common way to block main thread is to call dispatch_sync
on the same thread you dispatching. Sometimes you call same code from dispatch_once
.
It sounds like you've blocked the main thread somehow. To debug, run the app in the debugger and when the app freezes, hit the pause button above the log area at the bottom of Xcode. Then on the left side, you'll be able to see exactly what each thread is doing, and you can see where it's getting stuck.
Probably either a long loop on the main thread or a sync deadlock.