# BUG: Unity Editor hangs when handling DEVICELISTCHANGED callback

**URL:** <https://qa.fmod.com/t/bug-unity-editor-hangs-when-handling-devicelistchanged-callback/19021>\
**Category:** FMOD Engine\
**Tags:** unity\
**Created:** [July 18, 2022, 9:26pm UTC](https://qa.fmod.com/t/bug-unity-editor-hangs-when-handling-devicelistchanged-callback/19021 "2022-07-18T21:26:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reification](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@Reification](https://qa.fmod.com/u/Reification)\
**Post date:** [July 18, 2022, 9:26pm UTC](https://qa.fmod.com/t/bug-unity-editor-hangs-when-handling-devicelistchanged-callback/19021/1 "2022-07-18T21:26:19Z")

</div>

SETUP:  
Alienware m17 laptop  
Windows 10  
Unity 2019.4.36f1  
FMOD (UnityAudio disabled)

PROBLEM: Unity Editor hangs during DEVICELISTCHANGED callback if FMOD API is accessed. Specifically, the endpoints are:

- CoreSystem.getDriver
- CoreSystem.getNumDrivers
- CoreSystem.getDriverInfo

Attaching debugger shows that the stuck call is:  
RuntimeManager.DrawDebugOverlay (Line 728) =\> Memory.GetStats(Line 924), called with blocking = true.

Callback was triggered by switching system device.

No other calls appear to be stuck and FMOD music continues to play.

---

<div class="post-metadata">

**Author:** ![Reification](https://avatars.discourse-cdn.com/v4/letter/r/9f8e36/32.png) [@Reification](https://qa.fmod.com/u/Reification)\
**Post date:** [July 18, 2022, 9:27pm UTC](https://qa.fmod.com/t/bug-unity-editor-hangs-when-handling-devicelistchanged-callback/19021/2 "2022-07-18T21:27:55Z")

</div>

FAILED WORK AROUND: Disable stats. Registered callback is not received, and program hangs in editor when playing is stopped. While playing switching devices cause problems indicated by console warning:

```auto
[FMOD] AsyncCommandBuffer::growBuffer : Growing command buffer to 524288 bytes. Initial command buffer size can be tuned to avoid dynamic growth using Studio::System::setAdvancedSettings()

UnityEngine.Debug:LogWarning (object)

FMODUnity.RuntimeUtils:DebugLogWarning (string) (at Assets/Plugins/FMOD/src/RuntimeUtils.cs:533)

FMODUnity.RuntimeManager:DEBUG_CALLBACK (FMOD.DEBUG_FLAGS,intptr,int,intptr,intptr) (at Assets/Plugins/FMOD/src/RuntimeManager.cs:86)

FMOD.Studio.System:getBus (string,FMOD.Studio.Bus&) (at Assets/Plugins/FMOD/src/fmod_studio.cs:444)

FMODUnity.RuntimeManager:ApplyMuteState () (at Assets/Plugins/FMOD/src/RuntimeManager.cs:1447)

FMODUnity.RuntimeManager:Update () (at Assets/Plugins/FMOD/src/RuntimeManager.cs:537)

```

WORKAROUND: Set (in a thread-safe way) a flag to trigger updating devices on the main Unity thread.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [July 25, 2022, 2:15am UTC](https://qa.fmod.com/t/bug-unity-editor-hangs-when-handling-devicelistchanged-callback/19021/3 "2022-07-25T02:15:06Z")

</div>

I have not noticed any hangs when calling the FMOD API inside a `DEVICELISTCHANGED` callback. How long is it hanging for?  
Would it be possible for you to share a code snippet of your callback?
