Android performance optimization series-VSYNC and androidvsync
Concepts
The GPU obtains graphical data for rendering. The hardware displays the drawn data on the screen. To make the screen smoothly displayed, the Frame Rate must be above 60, that is to say, a draw operation can take up to 16.7 ms.
Frame Rate and Refrash Rate are not always the same. If the GPU is drawn at a speed greater than the screen refresh speed, truncation occurs because the GPU uses a piece of memory to draw Frame data, the new image frame will overwrite the old image frame from top to bottom. When the screen is refreshed, the current data status of the buffer zone is unknown, this captures a frame of data that has not been drawn in the GPU.
The solution is double buffering. The GPU first writes the frame data to the back buffer, and then copies it to the frame buffer in another region. When the next frame is drawn, the data is first written to the back buffer. When the screen is refreshed, it is only obtained from the frame buffer. If the GPU is writing back buffer, refresh the screen and VSYNC will stop the copy process.
VSYNC or vertical synchronization, will basically keep this copy operation from back buffer to frame buffer from happening if the screen is in the middle of refreshing from it.
When the GPU is drawn at a speed lower than the screen refresh speed, that is, FrameRate <RefreshRate, a choppy phenomenon is displayed on the screen. Therefore, make sure that the frame is drawn for less than 16 ms.
Reference
Android Performance Patterns: Understanding VSYNC