Audio latency on Unity 3d Android Platform

December 19, 2017




If you are a Unity Android developer, then you must have experienced an issue related to audio latency in some or many Android devices while using the unity's default audio source.

The ideal latency

(Image source: Google)

While creating an audio effect, the latency between the user's interaction with the game and the time of hearing the sound by the user should be less than 25ms else the user may experience a noticeable delay in audio playing.
On an iPhone, the value varies somewhere from 15ms to 20ms, which feels awesome from user experience but on many Android devices, this value drastically increases to 200-300ms, which doesn't feel as awesome as the previous one. One can feel a noticeable delay in the playing of audio with this much latency.

Why this audio lag?
There are a variety of Android devices on the market, from as low as a single core processor to as high as octa-core (even deca-cores). Unity audio system is made to work evenly and uniformly across all devices, either it is Windows, IOS, or Android.

(Image source: Google)

Due to high variance in specifications of Android devices, the audio system works slightly different across all devices. The latency varies from as low as 5-10 milliseconds to as high as around 1000ms. The issue is most common in Android devices due to their variance in specifications. Though, not all, but many Android devices face this issue.

Possible fix to reduce this latency, Well maybe...
I have tried all of the below methods that I found on the internet to reduce the audio lag. Trust me, none of them worked for me:
In AudioSettings, setting the latency to best latency 
Audio files should be in wav format
All audio data should be set to "decompress on load"
AudioSources bypass all the effects

The best fix...
After spending hours of searching this issue and implementing the various fixes, I came up with the conclusion that Unity default audio system is not going to work for you if you are going to target an android device. The best possible solution is to use Android's native audio system over Unity's audio system. Yes, you heard it right, changing the complete audio system implementation to Android's native implementation. This could be really a bulky process if have already coded your Audio system. But for new projects, it could be a game changer.

I will soon be creating a blog on how to implement this in Unity and provide a link here. 

Stay tuned...
Thanks for the read :-)

You Might Also Like

0 comments