Version: 2020.3
Language : English
Optimizing Performance on iOS
Measuring performance with the built-in profiler

iOS-specific optimizations

This page details optimizations that are unique to iOSApple’s mobile operating system. More info
See in Glossary
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 backendA framework that powers scripting in Unity. Unity supports three different scripting backends depending on target platform: Mono, .NET and IL2CPP. Universal Windows Platform, however, supports only two: .NET and IL2CPP. More info
See in Glossary
, 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 IL2CPPA Unity-developed scripting back-end which you can use as an alternative to Mono when building projects for some platforms. More info
See in Glossary
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 renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary
loop, which is set to 30 frames per secondThe frequency at which consecutive frames are displayed in a running game. More info
See in Glossary
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.


  • 2018–06–14 Page amended
Optimizing Performance on iOS
Measuring performance with the built-in profiler