Переход на 120-Гц дисплей ProMotion вскрыл hitch'и — каков бюджет кадра и что их чинит?
После перехода приложения на 120-Гц устройство ProMotion пользователи сообщают о hitch'ах, невидимых при 60 Гц. Ниже вывод инструмента Animation Hitches для скролла.
Объясните бюджет кадра при 120 Гц, что показывает вывод и что чинит hitch'и.
Animation Hitches
Refresh rate 120 Hz (8.3 ms budget)
Hitch time ratio 14 ms / s (target < 5 ms/s)
Longest hitch 41 ms (commit overran the budget)
Cause (frame) layoutSubviews → image decode on main
Объясните, что чинит hitch'и.
При 120 Гц бюджет кадра ~8.3 мс — половина от 16.7 мс при 60 Гц — так что прежняя работа переполняет и даёт hitch. Animation Hitches сообщает hitch-time ratio и долгий hitch, здесь 41 мс от декодирования в layoutSubviews. Уберите декодирование с главного.
- ✗Думают, что бо́льшая частота даёт больше времени на кадр, а не меньше
- ✗Читают инструмент как средний FPS вместо hitch-time ratio
- ✗Считают, что бюджет 16.7 мс не меняется при 120 Гц
- →Почему тот же код даёт hitch при 120 Гц, но не при 60 Гц?
- →Что hitch-time ratio измеряет такого, что упускает сырой FPS?
A hitch is a frame delivered later than the display needed it. At 60 Hz you had a 16.7 ms budget per frame; at 120 Hz the display asks for a frame every 8.3 ms, so the budget halves. Work that squeaked in under 16.7 ms now overruns 8.3 ms and shows as a hitch — which is why the same build looked fine at 60 Hz and janks on ProMotion.
120 Hz → 8.3 ms budget (was 16.7 ms at 60 Hz)
Hitch time ratio 14 ms/s → well over the <5 ms/s target
Longest hitch 41 ms → ~5 frames missed in one commit
Blamed frame layoutSubviews → image decode on the main thread
The Animation Hitches instrument's key number is the hitch-time ratio (ms of hitch per second of animation), not average fps — an app can average 110 fps and still hitch badly. The readout blames synchronous image decode inside layoutSubviews. Fix it by moving decode off the main thread (downsampled, cached), caching computed layout, and shrinking per-frame main-thread work until each commit fits inside 8.3 ms.