DevPrep

All topics › Performance

What are hangs and hitches? Why must the main thread stay free?

Middle PRO

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:

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

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store