Concept
- Vsync,vertical Synchronization
- Refresh Rate Screen A second number of refreshes, determined by the hardware, unit Hz, typically 60Hz
- Frame rate GPU Draws the number of frames in one second, unit fps (Frames per second)
Specific explanations
The GPU obtains the graphics data to draw, the hardware will draw the good data to present on the screen, in order to make the picture on the screen smooth display, needs to maintain frame rate above 60, namely the time draw operation not more than 16.7ms.
Frame rate does not always coincide with Refrash rate, and truncation occurs if the GPU draws faster than the screen refresh, because the GPU uses a piece of memory to draw frame data, and the new image frame overwrites the old image frame from the top to the next line. When the screen refreshes, the current data state of the buffer is not known, which captures a frame of data that has not yet been drawn in the GPU.
The workaround is a double-buffering technique (double buffering), where the GPU first writes the frame data to the back buffer and then copies it to another area of frame buffer. When the next frame is drawn, the data is first written to the back buffer, and the screen is refreshed only from frame buffer. If the GPU is writing back buffer and the screen is refreshed, VSYNC will block the copy process.
VSYNC or vertical Synchronization,will basically keep this copy operation from the back buffer to the frame buffer from happening If the middle of refreshing from it.
When the GPU is drawing slower than the screen refresh rate, that is framerate < RefreshRate, you will see a lag on the screen. So try to make sure that the drawing time of a frame is less than 16ms.
Reference
Android Performance Patterns:understanding VSYNC
Android Performance Optimization Series--vsync