How to answer
Both come from the main thread missing a deadline, but at very different scales and with different symptoms. A hitch is a frame shown later than expected during scrolling or animation: a few milliseconds over the 8.3 ms budget at 120 Hz, which the user sees as stutter. A hang is the main thread being busy or blocked long enough that the app stops responding to input: around 100 ms starts to feel slow, and 250 ms or more is what Instruments, Xcode Organizer and MetricKit report as a hang. Hitches are measured as a hitch time ratio (milliseconds of hitch per second of motion); hangs are measured as durations and counts, with the main thread's stack at the time. So I use the Animation Hitches template and hitch metrics for smoothness, and the Hangs instrument, Organizer and MetricKit hang diagnostics for responsiveness.
Key points
- Hitch: frame late by n ms. Ratio (Apple's WWDC20 guidance): under 5 ms/s is good, 5–10 ms/s is noticeable, over 10 ms/s is bad; Xcode Organizer's Hitches metric grades more loosely (≤ 10 ms/s good, ≤ 25 warning, ≤ 50 critical). Two kinds: commit hitches (your main-thread work: layout,
body, image decoding, text measurement) and render hitches (the render server: offscreen passes, huge layer trees, blur and mask effects) - Hang: main run loop not handling events. Can be busy (CPU work on main) or blocked (waiting on a lock, semaphore, synchronous I/O or another thread); Time Profiler only shows the busy kind, so check thread states for the blocked kind
- Watchdog: a long hang during launch, resume or scene transitions gets the app terminated (
0x8badf00din crash reports) - Lab tools: Hangs instrument (250 ms default threshold, configurable; the Animation Hitches template lowers it to 33 ms), Hitches instrument in the Animation Hitches template, SwiftUI instrument for long view updates, Thread Performance Checker in the scheme diagnostics, on-device hang detection in Settings › Developer
- Field tools: Organizer Hangs report; MetricKit
applicationResponsivenessMetrics(hang-time histogram),hangDiagnostics(stack + duration),animationMetrics.scrollHitchTimeRatioandhitchTimeRatio - Tests:
XCTOSSignpostMetric.scrollingAndDecelerationMetric, andXCTHitchMetric(application:)in XCTest performance tests
If they dig deeper
Why ratios for hitches: a 300 ms scroll with one 20 ms hitch and a 10 s scroll with one 20 ms hitch feel different, so time is normalized by motion time. Why hangs need stacks: the cause is usually one call (a synchronous fetch, a DispatchQueue.main.sync, a semaphore wait), so a hang diagnostic's main-thread stack is often enough. Shorter stalls (100–250 ms, sometimes called microhangs) fall under the reported-hang threshold but users still feel them on taps; lower the Hangs threshold to find them. Swift 6 framing: @MainActor code is still main-thread code; async only helps if the work is suspended or moved to a @concurrent function.
Common pitfalls
Calling every stutter a "hang" (or reporting FPS instead of hitch time). Looking for hangs in Time Profiler alone when the main thread was blocked, not busy. Fixing a commit hitch with GPU tricks, or a render hitch by moving code off main. Measuring in the simulator, where the Mac's CPU and GPU hide both. Ignoring field data, because lab devices are faster and less loaded than users' phones.
How to use it
| Hitch | Hang | |
|---|---|---|
| Symptom | Stutter while moving | Taps ignored, UI frozen |
| Scale | A few ms past the frame deadline | ≥ 250 ms reported (≥ 100 ms felt) |
| Metric | Hitch time ratio (ms/s) | Count, duration, main-thread stack |
| Lab | Animation Hitches, SwiftUI instrument | Hangs, Time Profiler, thread states |
| Field | MetricKit animationMetrics, Organizer | MetricKit hang metrics and diagnostics, Organizer |
Field data for both, with the MX MetricKit API (the iOS 26 fallback; MetricManager reports the same on iOS 27+):
import MetricKit
func logResponsiveness(_ payload: MXMetricPayload) {
if let animation = payload.animationMetrics {
print("scroll hitch ratio:", animation.scrollHitchTimeRatio) // ms of hitch per s of scrolling
print("hitch ratio:", animation.hitchTimeRatio) // all animations
}
if let responsiveness = payload.applicationResponsivenessMetrics {
let histogram = responsiveness.histogrammedApplicationHangTime // distribution of hang durations
for case let bucket as MXHistogramBucket<UnitDuration> in histogram.bucketEnumerator {
print(bucket.bucketStart, "–", bucket.bucketEnd, ":", bucket.bucketCount)
}
}
}
func hangReports(_ payload: MXDiagnosticPayload) -> [(duration: Measurement<UnitDuration>, stack: Data)] {
(payload.hangDiagnostics ?? []).map { hang in
(hang.hangDuration, hang.callStackTree.jsonRepresentation()) // main-thread stack: symbolicate server-side
}
}A hitch regression test in XCTest:
import XCTest
final class FeedResponsivenessTests: XCTestCase {
@MainActor
func testScrollingHitches() {
let app = XCUIApplication()
app.launch()
let feed = app.collectionViews["feed.list"]
let options = XCTMeasureOptions()
options.invocationOptions = [.manuallyStop]
measure(metrics: [XCTHitchMetric(application: app)], options: options) {
feed.swipeUp(velocity: .fast)
stopMeasuring()
feed.swipeDown(velocity: .fast) // reset, not measured
}
}
}Best practices
- Name the problem precisely: hitch (smoothness, ms/s) or hang (responsiveness, duration)
- Use Animation Hitches for hitches; Hangs plus thread states for hangs, so blocked time isn't missed
- Fix commit hitches by doing less main-thread work per frame, render hitches by simplifying layers and effects
- Watch MetricKit and Organizer per release; lab numbers alone are optimistic
- Guard key scrolls with hitch metrics in performance tests
Related concepts
- Main thread, scroll performance, animation performance, offscreen rendering, Time Profiler, SwiftUI performance instrument, MetricKit, performance testing, Instruments run comparison