Google is committed to advancing racial equity for Black communities. See how.

Frame Pacing Library Overview

The Android Frame Pacing library, also known as Swappy, is part of the Android Game SDK. It helps OpenGL and Vulkan games achieve smooth rendering and correct frame pacing on Android.

Frame pacing is the synchronization of a game's logic and rendering loop with an OS's display subsystem and underlying display hardware. The Android display subsystem was designed to avoid certain visual artifacts, such as tearing. The display subsystem avoids tearing by doing the following:

  • Buffering past frames internally
  • Detecting late frame submissions
  • Continuing to display the current frame when a late frame is detected

Inconsistent frame display times are caused by a game's render loop running at a different rate than what the native display hardware supports. Problems arise when a game's render loop runs too slowly for the underlying display hardware, leading to inconsistent display times. For example, when a game running at 30 fps attempts to render on a device that natively supports 60 fps, the game's render loop causes a repeated frame to remain on the screen for an extra 16 ms. This type of disconnect creates substantial inconsistencies in frame times such as 33 ms, 16 ms, 49 ms, and so on. Overly complex scenes further compound this problem because they cause missed frames to occur.

The Frame Pacing library performs these tasks:

  • Compensates for stuttering due to short game frames.
  • Uses sync fences for long frames that lead to stuttering and latency.
    • Injects waits into the app. These allow the display pipeline to catch up, rather than allowing back pressure to build up.
    • Uses sync fences (EGL_KHR_fence_sync and VkFence).
  • Chooses a refresh rate to provide flexibility and a smooth presentation, if your device supports multiple refresh rates.
  • Provides stats for debugging and profiling using frame stats.

To learn how to configure the library to operate in different modes according to what you need, see Supported operating modes.

To implement using OpenGL renderer or Vulkan renderer, see

To read more, see Achieve proper frame pacing.