Search Unity

Question How can I resolve big performance hits from ARSession.Update() on Android?

Discussion in 'Unity MARS' started by azevedco, Dec 9, 2021.

  1. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    Hi,
    We've got a scene setup with MARS to utilize facial tracking. In editor using the sample recordings, it runs pretty smooth. However, when we build to Android, i've noticed in the profiler, we get some pretty major hits on performance relating to ARSession.Update().
    Here's an image from the profiler:

    upload_2021-12-9_14-1-4.png

    There's also not a whole lot of additional complex logic going on inside the scene.
    I've read that doing the following two lines would help if this is due to some throttling:
    Code (CSharp):
    1. Application.targetFrameRate = 60;
    2. ArSession.matchFrameRate = false;
    However, I can't for the life of me find where to access ARSession with MARS.
    Any guidance on this would be very much appreciated.

    Edit for additional info:
    Unity version - 2020.3.12
    MARS version - 1.3.1

    Cheers,
    azevedco
     
  2. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    199
    MARS creates an internal ARSession - however if you already have one in your scene MARS will use it instead. So just add an ARSession to your scene and just access it directly.

    Out of curiosity, what android device is this?
     
    azevedco likes this.
  3. azevedco

    azevedco

    Joined:
    Mar 2, 2014
    Posts:
    34
    Awesome, thanks for your response CiaranWills!
    The device I tested on is the Google Pixel 5.