Member-only story
Android Internals for Rendering a View
Making a great performing app is only possible by knowing what is going under the hood

If you haven’t read about Understand How View Renders in Android please check it out for better understanding. As some of us are more interested in digging to know more details—like what are the components used while rendering, what was the display pipeline, and how the sync happens between UI and hardware—below are the answers. To know the answers to the above questions, we need to know the basic components listed below
- UI thread
- Render Thread
- Choreographer
- VSYNC
- BufferQueue
- SurfaceFlinger
- SurfaceView
- Display Pipeline
UI Thread
Every app has its special thread that runs UI objects, such as view objects; this thread is called the UI thread. Only objects running on the UI thread have access to other objects on that thread.
Simply saying UI thread prepares a pipeline of commands to be executed on the Render thread. Technically speaking, UI thread is responsible for creating the information by processing the lifecycle of a view. This means UI thread runs the onMeasure(), onLayout(), onDraw() of views and collects that information and passes it to Render thread.

For example, let’s consider there was a click event on a view. UI thread handles the input events; if there were any property changes in views then a traversal happens to measure the views. After positioning and laying the views phase happens. The last phase is drawing the views based on the above information. If the above information is ready then we sync that information from UI thread to Render thread.
Render Thread
Render thread is a component that has been introduced in Android Lollipop. It takes the inputs from UI thread and handles them to GPU. We assume that UI thread and Render thread work sequentially because render…