Google has launched the Android Game SDK, a set of libraries for Android game developers.
The first library to launched is designed to help developers with frame pacing, the synchronization of a game’s rendering loop with the OS display subsystem and underlying display hardware.
Writing about the new release, Dan Galpin, Google Developer Advocate, explained that Android’s display subsystem is designed to avoid tearing that occurs when the display hardware switches to a new frame in the middle of an update. To stop this happening, it buffers past frames, and if it detects late frame submissions, repeats the display of the old frames. This can cause strange behavior when game render loops run at a different rate to the native display hardware because of mismatches in synchronization.
The Frame Pacing library uses Android’s Choreographer API for synchronization with the display subsystem, using presentation timestamp extensions on both OpenGL and Vulkan APIs to make sure frames are presented at the proper time, and sync fences to avoid buffer stuffing. Multiple refresh rates are handled if supported by the device, giving a game more flexibility in presenting a frame. For a device that supports a 60 Hz refresh rate as well as 90 Hz, a game that cannot produce 60 frames per second can drop to 45 FPS instead of 30 FPS to remain smooth. The library detects the expected game frame rate and auto-adjusts frame presentation times accordingly. The Frame Pacing library allows games to take advantage of higher refresh rate 90 and 120 Hz displays, while also making it easy to lock the refresh rate to a desired value, regardless of the underlying display refresh rate.
The Frame Pacing library is built into Unity versions 2019.2 and beyond. To use it, you just select the optimized Frame Pacing checkbox under Android Settings to enable smoother frame rates for your game. The developers say that if you have source to your game engine, it’s straightforward to integrate the library into your OpenGL or Vulkan renderer.