What are hangs and hitches? Why must the main thread stay free?
Essence
The main thread handles touches, runs your UI code and prepares every frame. While it's busy, the app neither responds nor draws. Responsiveness problems come in two kinds:
- Hang — the main thread doesn't process events for a noticeable time: a tap doesn't register, scrolling doesn't start. Apple counts a block of 250 ms or more as a hang; users notice a delay from about 100 ms.
- Hitch — a frame is delivered later than it should have appeared on screen, and an animation or scroll stutters. The frame budget is 16.7 ms at 60 Hz and 8.3 ms at 120 Hz (ProMotion).
Hitches are measured as the hitch time ratio — milliseconds of lateness per second of animation. Apple's guidance: under 5 ms/s is good, 5–10 is noticeable, over 10 is bad.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep