Search Unity

Feedback OnDemandRendering in URP Android doesn't work too well

Discussion in 'General Graphics' started by Epsilon_Delta, Mar 2, 2023.

  1. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
    I am using OnDemandRendering with URP on Android with targetFramerate 60 and when I set the renderFrameInterval to 6 or more, I start to hear audio cracks.

    Moreover I thought the change from 6 to 1 would be immediate, but it seems it waits until next frame is rendered with the old interval so there is a lag (0.1s in my case) which makes this feature basically useless for anything more than very basic settings.
    For example in my case, I would like to go from interval 10 to 1 when there is any input (exactly like in the example from Unity docs on this topic), but I can't due to a lag.

    Next thing is that the canvases flicker in the editor but this was probably fixed in newer versions of the editor (2022.2)
     
    AlejMC likes this.
  2. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    The audio cracking issue you are experiencing may be related to the fact that On Demand Rendering (ODR) allows the CPU to run more frequently, potentially causing audio buffering issues. One possible solution is to increase the audio buffer size to ensure that it can handle the increased CPU load. This can be done by adjusting the "DSP Buffer Size" setting in the Audio Project Settings.

    As for the lag you are experiencing when changing the renderFrameInterval, this is a known issue with ODR. Unfortunately, there is no easy workaround for this, as the lag is inherent to the way ODR works. One possible solution is to use a different approach to reducing the frame rate, such as lowering the target frame rate or using dynamic resolution scaling.

    Regarding the flickering issue with canvases in the editor, as you mentioned, this has been fixed in newer versions of the editor. Upgrading to the latest version may solve this problem.
     
    Epsilon_Delta likes this.
  3. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
    There are 4 options in DSP Buffer Size: Default, Good Latency, Best Latency, Best Performance. None of the options prevented audio cracks.

    ODR works well enough with the intervals 2 and 3 which means 30 and 20 FPS in my case. I am going to use these values. I just hoped I could use higher interval values, because I have parts of my game that are completely static, but I cannot afford the input (and visual) lag and the audio cracks.

    Thanks for the reply.
     
  4. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
    Okay I take it back, even with the interval set to 2 I hear audio cracks no matter the audio settings, which renders this feature unusable for me.
     
  5. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
    I played with these settings:
    https://forum.unity.com/threads/dsp...es-why-isnt-it-a-setting-per-platform.447925/
    Code (CSharp):
    1. var configuration = AudioSettings.GetConfiguration();
    2. configuration.dspBufferSize = 32;
    3. AudioSettings.Reset(configuration);
    and when I set buffer size to 32, the cracking is gone, but sounds are louder and deeper (I would say the quality is better). However I don't know what are the implications of such small buffer, I read that it puts a pressure on CPU.
     
  6. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    258
    Don't they explicitly say here that there should be no input lag? https://blog.unity.com/technology/how-on-demand-rendering-can-improve-mobile-performance
    Or they are strictly speaking about the "Input lag" which is a different issue albeit perceived similarly by the viewer?
     
  7. dogmachris

    dogmachris

    Joined:
    Sep 15, 2014
    Posts:
    1,375
    Of course it does, because audio has now to be processed more frequently. You may have to optimize somewhere else to make up for this.

    Unity says there should be no input lag. But that's like saying you can eat all the cake you want and still lose weight. It's a nice idea in theory, but in reality, there are always tradeoffs. In the blog post you linked, Unity is talking specifically about input lag caused by rendering, which is different from the input lag that can be caused by other factors, such as the buffer size of the audio system.

    So while Unity may say there should be no input lag, the reality is that on-demand rendering can introduce latency, especially if your hardware is not powerful enough to keep up with the demands of the scene.

    There are trade-offs if you want to preserve the complexity of your scene: reduce workload and increase latency or vice versa. If you can't find a balance, maybe your best shot would be to reduce the complexity of your scene.
     
  8. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    I'm running into the lag issue too.

    I swear I've tried ODR in the past where there was no perceivable lag when changing from 1 to say 20 ODR interval. It was smooth, instantaneous. But in 2022.3 on Android the ODR interval change causes noticeable hitching in rendering. This is not present in the editor. I feel like this is a bug - the visual hitch is so significant it makes it unusable.
     
  9. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    1,123
    The lag is not present in the Beta version of Unity. I can't speak for the audio popping, but as far as lag goes it is fixed.

    However sometimes the app gets stuck in a very very very laggy state when restoring from background. Requires you to suspend the app and restore it again to "fix" it.