Search Unity

Resolved iOS Performance issues when using post processing and arfoundation (URP)

Discussion in 'AR' started by Cery_, Jan 12, 2023.

  1. Cery_

    Cery_

    Joined:
    Aug 17, 2012
    Posts:
    48
    I am currently experiencing some performance issues when combining ARFoundation and PostProcessing.

    Here is the setup:
    Unity 2021.3.16, ARFoundation 5.1.0-pre2, URP 12.1, default volume based PostProcessing
    Target: iOS

    It seems like PostProcessing is negatively influencing the calculation on the ARKit/ARCore site. With PostProcessing active the ARSession.Update() takes 6ms and if it is inactive it only takes 0.155ms. The rendering of the PostProcessing itself only adds around 0.2ms.

    My only explanation for this so far is that the additional textures, GPU memory and rendertarget switches stall the processing of the AR system which also heavily relies on the GPU (I think).

    Maybe anyone has another possible explanation or more details?
    I will try to investigate further. I don't really trust the unity profiler to make conclusions about the GPU.

    I will see if i can get more info from with metal profiling but i don't have a lot of experience with that. - Maybe someone has a hint how/where to look?

    Without PostProcessing on IPad Pro:
    postprocessing_disabled(iOS).png
    With PostProcessing on IPad Pro:
    postprocessing_enabled(iOS).png
     
  2. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    This will require more research on our end. So we can get it on our todo list would you file a bug and then post the bug ID here?

    https://unity.com/releases/editor/qa/bug-reporting

    My guess is increased memory usage and processing impact could be causing stalls when attempting to access memory and or the device is getting hot but can't say for sure.
     
    Cery_ likes this.
  3. Cery_

    Cery_

    Joined:
    Aug 17, 2012
    Posts:
    48
    Yes I will do that on monday! It happens right after starting the session so i think it is not related to device temperature. Stalling caused by the increased memory/processing sounds possible.
     
  4. Cery_

    Cery_

    Joined:
    Aug 17, 2012
    Posts:
    48
    I haven't created a bug report so far because i didn't come around to create an isolated project that reproduces the issue.
    Currently I am guessing it might also be related to our rendering path. We compose the camera image after doing post processing on the 3D objects.
    My guess is that the system doesn't like that we use the camera image after rendering post processing. It seems that it hands over something and then the system stalls a frame until the ar update of the next frame is done and hands back the resources.
    Is the "PrepareRenderTarget" call part of the current pass or the next pass? -it seems to stall the pass before we need the camera image.
     

    Attached Files:

  5. Cery_

    Cery_

    Joined:
    Aug 17, 2012
    Posts:
    48
    After a lot of testing my current conclusion is that it is not related to a desync of the AR System and the rendering process.
    After debugging with metal instrumentation and debugger it seems that the unity profiler is just way off.
    The post processing affects the rendertimes quite substantially (from 7ms without to ~12ms). Seeing that the rendering is so close to the 16ms mark i think its quite possible that the GPU stalls the AR system execution in the next frame.
    So if I reduce the load on the GPU I should be able to tackle this issue.
    During testing I also got different behaviour from time to time. It does not correlate 100%. Contrary to my first tests where switching post processing instantly resulted in different performance I had some situations where post processing could be enabled with great performance and vice versa. But It always follows clear steps so no smooth transition between. I haven't been able to correlate the Metal GPU Performance state with the different AR Update times but there is a clear correlation between enabling post processing and it switching to maximum performance mode.

    All tests on an Apple A12Z GPU IPad pro btw.
    I will leave it like this for now. Maybe this profiling/debugging info is of use for someone.
    Maybe someone knows how to get better GPU timings in the profiler?
    The FrameTimingManager seems to report correct values.