Documentation

Unity Engine

Download Unity

Unity Engine

Optimize application startup times

Report when your application finishes initialization and analyze startup data to optimize the application startup process.
Read time 2 minutesLast updated a day ago

Android can optimize the application startup process to reduce the time it takes for the application to become interactive. To enable this optimization, report when your application finishes initialization and is ready for user interaction. Android uses this information to prioritize tasks that run before initialization completes. Android also records diagnostic data for each startup, which you can retrieve to analyze how and when the application started.

Report application startup completion

To report to Android that application startup is complete, use
DiagnosticsReporting.CallReportFullyDrawn
. By default, Unity calls this method when the first scene loads, before
Awake
. An application can perform additional tasks before it becomes interactive, such as loading resources before rendering to the screen. In this case, call
DiagnosticsReporting.CallReportFullyDrawn
on the frame when the application becomes interactive. If your code calls
DiagnosticsReporting.CallReportFullyDrawn
, Unity doesn't call the method automatically when the first scene loads.
Note
Android records only the first call to
CallReportFullyDrawn
and ignores subsequent calls. Don't call this method multiple times.

Retrieve application startup information

Android records diagnostic data for each application startup. You can use this data to run analytics and diagnostics, optimize startup times, and track how different settings affect startup performance.
To retrieve the startup records that Android stores for your application:
  1. Call
    ApplicationStartInfoProvider.GetHistoricalProcessStartReasons
    to get an array of
    IApplicationStartInfo
    records. To limit the number of records that the method returns, pass the
    maxNum
    parameter. Set
    maxNum
    to
    0
    to return all records.
    Note
    GetHistoricalProcessStartReasons
    requires Android 15 (API level 35) or later. On earlier versions, this method returns an empty array. The
    IApplicationStartInfo.startComponent
    property requires Android 16 (API level 36) or later and returns
    0
    on earlier versions.
  2. Read the properties of each record that you want to analyze, such as
    reason
    ,
    startType
    , and
    startupTimestamps
    .
GetHistoricalProcessStartReasons
returns the records sorted from most recent to least recent. Each record describes a single application startup, including why the process started, how it started, and the timing milestones that Android recorded during startup.
The following code example retrieves all startup records that Android stores for the application:
using UnityEngine;using UnityEngine.Android;public class LogApplicationStartInfoExample : MonoBehaviour{ private void Start() { LogApplicationStartInfo(); } private static void LogApplicationStartInfo() { // Get all available startup records sorted from most recent to least recent. #if UNITY_ANDROID && !UNITY_EDITOR IApplicationStartInfo[] results = ApplicationStartInfoProvider.GetHistoricalProcessStartReasons(); int total = results.Length; for (int i = 0; i < total; i++) { IApplicationStartInfo result = results[i]; if (result != null) { Debug.Log($"[ApplicationStartInfo] [{i + 1}/{total}]\n{result.ToString()}\n"); } } #else Debug.Log("[ApplicationStartInfo] Historical start reasons are only available on Android devices."); #endif }}

Additional resources