Animation Hitches in iOS Development

Make using your app delight by being aware of render loop

source: Apple Developer Talk

Hitch is a kind of performance issue where user feels rough while interacting with application. It may occur while scrolling, animation or transition between screens.

iPhone or iPad is having 60Hz refresh rate. Frame duration is 16.67 ms(1/60). When user starts interacting with the app, the new corresponding frames need to be rendered. This cycle of rendering new frames on to screen is “Render Loop”.

source: Apple Developer Talk

This Render Loop comprises of 5 stages as shown in above image.

Events are touches, keyboard presses or timers. Responding to these changes App View Hierarchy will be altered.

source: Apple Developer Talk

Changes corresponding to event from each view will be collected in next commit phase. These changes such as drawing image views or adding labels are applied to views from top to bottom and left to right. These collected changes were passed to Render Server.

In Render Prepare Phase the collected changes are pipelined in the order of top to bottom, left to right and back to front(layers).

Render Server executes this changes in next phase and displays them within a deadline. If any changes happened to miss the deadline causes the Hitches.

Hitches can occur in two stages of Render Loop

source: Apple Developer Talk

Commit Hitch

When commit phase takes extra time to prepare changes then Hitch occurred is Commit Hitch. Developer Tool Instruments from Xcode12 includes Animation Hitches measure. This also includes Time Profiler to detect and locate commit hitches.

Render Hitch

When execution of pipeline takes extra time then Hitch occurred is Render Hitch. Same Instruments can be used to detect the Render Hitches labeled as “Expensive Gpu” hitch type. To fix them Xcode View Debugger is to be used. Xcode introduces performance optimizations to suggest fixes for render hitches. Those can be viewed by enabling Show Performance Optimizations from Editor menu.

To Learn More about each hitch and fixes to solve them see Apple Developer Talks.

Thanks For Reading !!!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sai Durga Mahesh

Using Data Science to provide better solutions to real word problems