Legacy Documentation: Version 2018.2 (Go to current version)
Optimizing Performance on iOS
Measuring performance with the built-in profiler
Other Versions

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.

To access iOS Script Call optimization, navigate to the Player SettingsA settings manager that lets you set various player-specific options for the final game built by Unity. More info
See in Glossary
window (menu: Edit > Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your Project behave. More info
See in Glossary
> Player) and select the iOS icon (shown below).

iOS Icon - select this to access the iOS settings in the Player Settings window
iOS Icon - select this to access the iOS settings in the Player Settings window

Locate the Script Call Optimization setting in the _Other Settings section.

The options for this setting are:-

  • Slow and Safe - the default Mono internal call handling with exception support.
  • Fast but no exceptions - a faster implementation of Mono internal call handling. However, this doesn’t support exceptions and so should be used with caution. An app that doesn’t explicitly handle exceptions (and doesn’t need to deal with them gracefully) is an ideal candidate for this option.

Note: There is no performance benefit 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 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
. However, we recommend using Fast but no exceptions on release builds to avoid undefined behaviour.

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.

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 will sample the accelerometer 60 times per second. You may see some performance benefit by reducing the accelerometer sampling frequency and it can even be set to zero for games that don’t use accelerometer input. You can change the accelerometer frequency from the Other Settings panel in the iOS Player Settings.


Did you find this page useful? Please give it a rating:

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