Search Unity

Bug Audio distorted on some Android devices, even with 2019.4

Discussion in 'Audio & Video' started by adbourdages, Jan 4, 2021.

  1. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    75
    Hello,

    There has been a longstanding issue with our game on some Android devices (PC, Editor, iOS and most Android are fine): all the audio is completely distorted from the start of the game.

    This problem is well documented (link link) on users forums but I find it surprising that I cannot find anything about it here since it has been plaguing our live product for years. It tends to occur on OnePlus phones but after upgrading the game from 2018.3.14f1 to 2019.4.16f1 in December it is now happening much more widely and on new devices like the realme RMX1911.

    Beyond the aforementioned Unity version we also use MasterAudio for in-game audio management. Since that library uses AudioClip/AudioSource in the background, I am thinking it is unlikely to be the source of the issue. The audio compression used varies from ADPCM, aggressive MP3 compression and PCM. Memory-wise it is using streaming for background music, decompressed in memory and compressed in memory variants. For frequency compression we use mostly 44k and 22k. Most clips are set to mono.

    There are some workarounds that allow the game to start with normal audio:
    - launch the game while some other music is playing (Spotify, music player)
    - launch the game with headphones plugged in then disconnect them

    Which seems to point at a hardware initialization issue possibly? Has anyone have experience with this issue?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  3. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    75
    It does not appear to be but thanks for pointing it out.
     
  4. adbourdages

    adbourdages

    Joined:
    Jul 8, 2012
    Posts:
    75
    Well, in case anyone happens on this thread in the future: the problem was with the dspBufferSize audio settings. For years the game had used Best Latency (256) to combat Unity's audio latency and it had been working fine for most devices (exceptions being some OnePlusses/Mediatek devices). Following a lead from the NativeAudio plugin dev, I sent out a version with the audio at Good Latency instead (512) which solved the problem.

    So it seems that under some condition, the CPU couldn't keep up with the needs of the audio buffer.
     
    GlotzEulor and MD_Reptile like this.
  5. ThisGuise

    ThisGuise

    Joined:
    Oct 20, 2015
    Posts:
    9
    Thank you for updating the thread with a possible solution. I will try it out.