Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    105
    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?
     
  2. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,085
    Same happens in editor, mono and il2cpp builds.

    Code (CSharp):
    1. Obtained 9 stack frames
    2. 0x00007ff6895274c4 (Unity) purecall
    3. 0x00007ff6876132df (Unity) AudioClip::WWWRead
    4. 0x00007ff688ee63f6 (Unity) FMOD::UserFile::reallyRead
    5. 0x00007ff688ee6149 (Unity) FMOD::UserFile::reallyAsyncRead
    6. 0x00007ff688ec1f99 (Unity) FMOD::FileThread::threadFunc
    7. 0x00007ff688ebf706 (Unity) FMOD::Thread::callback
    8. 0x00007ff689550a10 (Unity) thread_start<unsigned int (__cdecl*)(void *),1>
    9. 0x00007ff9316074b4 (KERNEL32) BaseThreadInitThunk
    10. 0x00007ff9317826a1 (ntdll) RtlUserThreadStart
     
  3. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,085