A hang is the app freezing while someone waits: taps do nothing and scrolling stops. iPhone calls it a hang. Android
calls the long version an ANR, Application Not Responding, and offers to close the app. Both have one cause: the main
thread, which draws the screen and handles touches, is busy or blocked. Here's how to find hangs and ANRs and remove
them for good.
What counts
iPhone: Apple's tools report a hang when the main thread doesn't respond for more than 250 milliseconds ( Apple ). Xcode Organizer's Hangs report and the Hangs instrument both use that threshold.
Android: the system raises an ANR when the app doesn't respond to an input event within about five seconds, or when a broadcast receiver or service runs too long.…