August 03 2020

Unity: Optimized Frame Pacing for Smooth Gameplay

Let’s talk about the concept of frame pacing to learn how to reduce the performance stutters that your game suffers.

If you want smoother gameplay in your Android games, then this post is for you.

The Problem With the Frames Per Second (FPS) Metric

Your game renders at 60 FPS, so there is no reason to worry about performance, right?

… Right?



You see, Frames Per Second (FPS) is just an average.

Let’s say you and I go to a restaurant. Each of us order a burger…

But I am hungry and greedy. So I eat them both. I leave you with zero burgers 🙂

That’s ok for you, right? After all, in average, we ate one burger each.

That’s a mathematically true statement, but I bet that wouldn’t make you any happier.

So that’s exactly how the FPS metric can deceive you… by trusting averages.

In just 1 second, you can manage to render:

- VERY fast frames

- And also VERY slow frames

In other words: an uneven frame pace.

And yet… Your FPS counter can happily show you 60 FPS.

Showing 60 FPS would convince your boss to give you a promotion.

But you wouldn’t deserve it.

Why is that?

Oculus Quest Performance Metrics

Why Your Game Stutters Even at 60 FPS

A game stutters when its rendering speed is inconsistent and its frames are presented at varying rates in the screen.

A typical user will see some type of short of micropauses that annoy the hell out of them and possibly cause them to rage.

This perceived gameplay instability (stuttering) happens because some frames stay longer in your monitor than others… for the simple reason these frames are not available for when the screen demands.

Now, you might think v-sync can help you here… as it is always enabled on Android.

But nope. V-sync doesn’t help with performance stutters…

V-sync only helps with screen tearing.

Two different things.

No matter what, it’s hard to lie to our eyes in the area of game performance.

Here’s an example of input latency. Can you spot it?

What Solutions Are Out There?

Ideally, you have to destroy both performance stutters and screen tearing.

And here’s how:

  • [Against Stutters] Optimize your game so you always render within your performance budget, e.g. 16.67ms for 60 FPS.My Unity Performance Checklist can help you achieving high frame-rates.
  • [Against Tearing] Enable v-sync so you present frames when the screen says it’s fine.

Sounds good in theory…

But in real-life, you’ll always have troublesome situations. And you won’t like them.

Engineers know this.

That’s why we have solutions that reduce the ocular damage these performance problems cause to you and your fans.

And regarding game stutters, one of these solutions is Swappy for Android.

Let’s see how this weird name will help you.

Meet Swappy

I know, Swappy sounds like the name everyone would choose for a pet.

And it is a life savior!

Swappy is the frame pacing library that will help you achieve smoother rendering when you are in trouble.

Remember: frame pace is the speed (and consistency of speed) at which your game deliver its frames. And we want this pace to be even and consistent.

So, how does Swappy help?

You see, the operating system’s default behavior is to display the front-buffer in your screen. Aways.

And that’s fine when your game performs well… but when you have uneven frame pacing, then it’s not necessarily optimal.

You see, Swappy is smarter than that. This library chooses the best frame to display on your screen depending on how early — or how late— you are delivering your frames.

Its goal?

To improve the perceived frame-rate smoothness in these situations.

Swappy will choose to display either:

  • The current frame the GPU has just finished rendering.
  • Or the previous frame the GPU rendered a few milliseconds ago.

And it does so at the right time, i.e. when the screen is ready to display a new frame.

The mechanism behind this is relatively simple on the surface.

I’ll describe how Swappy works in a future post. In the meantime, you can give it a read here.

This library is designed to take advantage of the different refresh rates of your Android devices. Some mobile screens support 90 Hz and beyond nowadays.

And varying screen refresh rates help you achieve smoother gameplay as well.

Ok, let’s cut the chase. Can you use Swappy in Unity?

You bet you can.

And it’s stupidly easy on Unity 2019.2+.

It’s as simple as enabling “Optimized Frame Pacing” on the Android player settings.

Unity: Optimized Frame Pacing

As always, test this setting before deploying it to production.

See how it feels for you and other users.

What’s Next?

Remember, you should aim to deliver consistent frame-rates to prevent stutters from ruining your players’ experience (and your wallet).

Here’s an example of an angry user…

You don’t want that to happen in your project.

BIG nope.

If you want me to personally help you achieve higher frame-rates in your game, send me an email to [email protected] and we’ll get it sorted.


The Gamedev Guru Logo

Performance Labs SL
Paseo de la Castellana 194, Ground Floor B
28046 Madrid, Spain

This website is not sponsored by or affiliated with Facebook, Unity Technologies, or Gamasutra.

The content you find here is based on my own opinions. Use this information at your own risk.
Some icons provided by Icons8