Skip to main content

Measure and Optimise Startup Time

It is important to measure and optimise the startup time of your playable ads, as this can directly impact user experience.

Optimising startup time#

By optimising the startup time of your Unity scene, you will also improve the start up time of your playable.

  1. We recommend that you start by optimising by using the inbuilt Profiler in Unity.
  2. You may also use Chrome Dev Tools for more advanced optimisation.
  3. Smaller playables typically have shorter startup times - check out the guide for optimising assets.
  4. If you’re storing prefabs of entire levels, it’s a good idea to remove any objects not seen in the playable, this helps to reduce initial load times. Also, remove any prefabs that aren’t going to be used in the playable.

Here are some common techniques which may help you achieve a lower startup time.#

  • Remove/reduce heavy Awake/Start methods.
  • Avoid using GetComponent / FindObject calls which are slow and resource consuming, especially in update and fixed update methods only use them unless absolutely necessary.
  • Cache your references instead of dynamically finding them to avoid looking up objects as much as possible.
  • Avoid unnecessary physics collisions in your scene use the Physics Matrix - Edit > Project Settings, then select checkboxes to adjust the settings.
  • Physics - avoid unnecessary use of components like Continuous collision detection (CCD).
  • Avoid using particles systems with high amounts of particles (Unity has 1000 by default, whereas 50-100 is typically suitable for a playable ad).
  • Keep your project hierarchy tidy - avoid unnecessary nesting of objects, avoid deep nests.
  • Use ShaderVariantCollections with as few shaders as possible.
  • Disable Auto-Instantiate prefabs and avoid logic which retrieves prefab data.
  • If your scene requires many static objects, then consider baking them.
  • Avoid using too many objects in the scene, Luna doesn’t support batching yet. If you have a lot of objects that don’t move or move together, then bake them! (careful as this can increase size).
  • Unity Text is which is more optimal during gameplay than TMP_Text - use TMP for end cards, and Unity text for in game text.
  • Avoid using TMP_Text autosize if possible.

Measuring startup time#

If you want to measure startup time accurately, it is recommended to follow these instructions and test the playable on a range of devices.

  1. Upload your build to Luna Playground.
  2. Download an Applovin version of the playable ad.
  3. Open the downloaded .html file in an IDE of your choice.
  4. Enter the following script at the beginning of the <head> element:
<script>    var instantiateTime = Date.now();    function LogTime() {        var engineInitializedTime = Date.now();        alert("Loading time: " + (engineInitializedTime - instantiateTime) + " ms");    }</script>
  1. In the <body> section of the HTML file, find the StartWithJSCallback function, and add LogTime(). For example:
.StarWithJSCallback( function() {    //Add function here   LogTime();  ...  ...  ...})
  1. You may now test this HTML file on a device to measure the startup time. You will see the following:
images-xsmall