Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct here to familiarize yourself with the rules and how to post constructively.

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    Dismiss Notice

Bug Random crash on "Audio File Thread" when destroying AudioClip

Discussion in 'Audio & Video' started by rchapman, Jan 25, 2022.

  1. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    75
    We're seeing a random crash on "Audio File Thread" on Android if we rapidly create and then destroy an AudioClip from a UnityWebRequest with DownloadHandlerAudioClip. The stack trace usually looks like this:

    00331b99 /data/app/aws.asdasdwfixil2nostrip-QNUIB1xZIlsl4psQlmnDZQ==/lib/arm/libunity.so (AudioClip::WWWRead(void*, void*, unsigned int, unsigned int*, void*)+44) (BuildId: 362bf5cb6a16bdede9faa80e9f778ff4d10224f3) 2022-01-24 15:33:01.685 13389-15909/aws.asdasdwfixil2nostrip E/CRASH: #05 pc 013f315f /data/app/aws.asdasdwfixil2nostrip-QNUIB1xZIlsl4psQlmnDZQ==/lib/arm/libunity.so (FMOD::UserFile::reallyRead(void*, unsigned int, unsigned int*)+46) (BuildId: 362bf5cb6a16bdede9faa80e9f778ff4d10224f3)

    The AudioClip is set to be streaming, so my read on this is that the Audio File Thread is still trying to read the file into the AudioClip after it's been destroyed.

    We're looking for workarounds or solutions. It's not clear to me if there's any way to ensure this thread has stopped trying to use the AudioClip. Is there a property or something else we could monitor to determine if it's safe to destroy the clip? Would it be sufficient to Stop the AudioSource first then wait a short time (say 0.5s) before we destroy the Clip?
     
unityunity