Optimizing Performance on iOS
Measuring performance with the built-in profiler

iOS-specific optimizations

This page details optimizations that are unique to iOS deployment.

Script call optimization

Most of the functions in the UnityEngine namespace are implemented in C/C++. Calling a C/C++ function from a Mono script involves a performance overhead, so you can save about 1 to 4 milliseconds per frame using iOS Script Call Optimization setting.

A good development practice on iOS is to never rely on exception handling (either internally or through the use of try/catch blocks). When using the default Slow and Safe option, Unity catches any exceptions that occur on the device and provides a stack trace. When using the Fast but no Exceptions option, any exceptions that occur will crash the game, and no stack trace will be provided. In addition, Unity raises the AppDomain.UnhandledException event to allow project-specific code access to the exception information.

With the Mono scripting backend, the game runs faster since the processor is not diverting power to handle exceptions. There is no performance benefit with the Fast but no Exceptions option when using the IL2CPP scripting backend. However, when releasing your game to the world, it’s best to publish with the Fast but no Exceptions option.

Tuning accelerometer processing frequency

If accelerometer input is processed too frequently then the overall performance of your game may suffer as a result. By default, a Unity iOS application samples the accelerometer 60 times per second. You may see some performance benefit by reducing the accelerometer sampling frequency and you can even set it to zero for games that don’t use accelerometer input. You can change the Accelerometer Frequency setting under the Other Settings panel of the Player settings for the iOS platform.

Incremental builds

The C++ code generated by the IL2CPP scripting backend can be updated incrementally, allowing incremental C++ build systems to compile only the changes source files. This can significantly lower iteration times with the IL2CPP scripting backend.

To use incremental builds, choose the Append option after selecting Build from the Build Settings dialog. The Replace option performs a clean build.

Setting the frame rate

Unity iOS allows you to change the frequency with which your application will try to execute its rendering loop, which is set to 30 frames per second by default. You can lower this number to save battery power but of course this saving will come at the expense of frame updates. Conversely, you can increase the framerate to give the rendering priority over other activities such as touch input and accelerometer processing. You will need to experiment with your choice of framerate to determine how it affects gameplay in your case.

If your application involves heavy computation or rendering and can maintain only 15 frames per second, say, then setting the desired frame rate higher than fifteen wouldn’t give any extra performance. The application has to be optimized sufficiently to allow for a higher framerate.

To set the desired frame rate, change Application.targetFrameRate.


Optimizing Performance on iOS
Measuring performance with the built-in profiler