Does any body know what I have to check if my app freezes? I mean, I can see the app in the iPad screen but no buttons respond. I have tried debugging the code when I click on the button, but I haven't seen anything yet. I was reading about the Instruments tools; specifically how do I use them?
Can anybody help me? I just need an explanation about how use the tools.
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.
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
.
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.
来源:https://stackoverflow.com/questions/10196344/my-app-freezes-but-no-error-appears