Search Unity

Unity’s Android audio latency improvement in 2019.1.0

Discussion in 'Android' started by 5argon, Nov 2, 2018.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,261
    Screenshot 2018-11-02 08.52.38.png

    I read the alpha patch note and got excited, so I did some comparison test and would like to share the result. I have a phone (Xiaomi Mi A2) which I suspected got AudioTrack implementation in earlier Unity version because of its insanely slow Unity latency (but acceptable anywhere else on the phone, and in other games not made by Unity)

    Screenshot 2018-11-02 10.56.15.png

    The result is impressive, Comparing 2019.1.0a7 with 2018.3.0b7-built application the latency reduction is 200ms! There's no change in the phone that already using OpenSL ES before like Xperia Z5. I am guessing, many Chinese phones out there would greatly benefit from this upgrade.

    Here's an in-depth article if you are interested in reading more.
    https://gametorrahod.com/unitys-android-audio-latency-improvement-in-2019-1-0-ebcffc31a947
     
    Yury-Habets and Evaldas_Unity like this.
  2. Yury-Habets

    Yury-Habets

    Unity Technologies

    Joined:
    Nov 18, 2013
    Posts:
    1,052
    Hi!

    Thanks for your post!

    You are correct, with this change Unity will be using OpenSL more. We now enable it for devices which have buffer size reported <= 192 samples. This is a risky change, and I think the probability of getting a regression is higher than 0.

    It's not correct that Unity makes decision on "use OpenSL or not" based only on the low_latency_audio flag. The logic is a bit more complicated, to mitigate issues like
    https://forum.unity.com/threads/android-sound-problem.359341/
    https://forum.unity.com/threads/bluetooth-headphones-sound-problems.376842/
    and others. In fact, even having the flag set doesn't mean OpenSL will be used (!).

    You know, I've seen much more than one phone having massive issues if you switch to OpenSL (quite a bit of them were Chinese phones btw). Unity is used to power games on hundreds of millions of devices, and it has to run well on all* of them (*well, as many as possible, not 100% for sure). This is why we have to take a conservative approach. "Let's switch on OpenSL everywhere, regardless of the flag" may lead to stuttering sound on some millions of phones, and terrible latency on another millions. This is just the tip of the iceberg. :)

    Thank you for following the Unity Android audio!
     
    AcidArrow and 5argon like this.