# FMOD waiting for user code in FMODUnity.dll to finish Executing

**URL:** <https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260>\
**Category:** Unity\
**Created:** [February 19, 2024, 11:25am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260 "2024-02-19T11:25:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeroByron](https://avatars.discourse-cdn.com/v4/letter/h/f19dbf/32.png) [@HeroByron](https://qa.fmod.com/u/HeroByron)\
**Post date:** [February 19, 2024, 11:25am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/1 "2024-02-19T11:25:08Z")

</div>

Hello  
Im having an issue where sometimes when i stop play mode in unity the editor gets stuck on this message

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/c/c3484ec18df72272ff1045dd26884f540764c4f1.png)

and it seems to not stop until i forcefully close unity  
I was wondering if anyone knew what was causing this

the FMOD version we use is 2022.2.18  
any info would be great Thanks

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [February 20, 2024, 2:08am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/2 "2024-02-20T02:08:10Z")

</div>

In FMOD for Unity’s settings, can I get you to set your [logging level to “Log”](https://www.fmod.com/docs/2.02/unity/settings.html#logging-level) and [enable API error logging](https://www.fmod.com/docs/2.02/unity/settings.html#enable-api-error-logging), and provide me with a log from when this issue occurs? Note that you’ll likely have to retrieve the log from the relevant Unity log directory instead of from the editor.

> [@HeroByron](#):
>
> the FMOD version we use is 2022.2.18

Can I also get both your Unity and FMOD for Unity plugin versions?

---

<div class="post-metadata">

**Author:** ![HeroByron](https://avatars.discourse-cdn.com/v4/letter/h/f19dbf/32.png) [@HeroByron](https://qa.fmod.com/u/HeroByron)\
**Post date:** [February 20, 2024, 8:23am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/3 "2024-02-20T08:23:29Z")

</div>

yep the unity version we are using is 2022.3.14f1  
and the fmod for unity version is also 2.02.18

---

<div class="post-metadata">

**Author:** ![HeroByron](https://avatars.discourse-cdn.com/v4/letter/h/f19dbf/32.png) [@HeroByron](https://qa.fmod.com/u/HeroByron)\
**Post date:** [February 26, 2024, 10:28am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/4 "2024-02-26T10:28:43Z")

</div>

Appologies ive only just seen the first part of the message i only say the second part asking for the unity and FMOD versions

ive set the settings up but cant seem to find any FMOD specific logs.  
do you know what i should be looking for  
thanks

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [February 27, 2024, 1:11am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/5 "2024-02-27T01:11:18Z")

</div>

> [@HeroByron](#):
>
> Appologies ive only just seen the first part of the message i only say the second part asking for the unity and FMOD versions

No problem!

> [@HeroByron](#):
>
> ive set the settings up but cant seem to find any FMOD specific logs.  
> do you know what i should be looking for

You’ll want to be looking for the log where you were able to reproduce the hang in Unity’s editor log directories - see [Unity’s documentation on Log Files](https://docs.unity3d.com/Manual/LogFiles.html) for the location on each platform.

---

<div class="post-metadata">

**Author:** ![Tombo\_Meta](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@Tombo\_Meta](https://qa.fmod.com/u/Tombo_Meta)\
**Post date:** [April 25, 2024, 10:01pm UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/6 "2024-04-25T22:01:35Z")

</div>

Sorry to hijack this thread, but I’m currently experiencing the same issue w/ my project.

I wasn’t having any luck with the Unity logs, so I opted for a different approach.

I saw in the box Unity displays that the chunk of code that was being waited on was ‘RuntimeManager.HandlePlayModeStateChange()’ so I dropped a breakpoint in there to see how far I could trace it.

Upon exiting play mode I was able to step through the following functions:

> FMODUnity.RuntimeManager.HandlePlayModeStateChange() [state = EnteredEditMode]  
> FMODUnity.RuntimeManager.Destroy()  
> UnityEngine.Object.DestroyImmediate()  
> FMODUnity.RuntimeManager.OnDestroy()  
> FMODUnity.RuntimeManager.ReleaseStudioSystem()  
> FMOD.Studio.System.release()  
> FMOD.Studio.System.FMOD\_Studio\_System\_Release()

Upon stepping into ‘FMOD\_Studio\_System\_Release()’ system appears to hang and I get the window pictured above.

Wondering if someone would be able to help me resolve this.

Thanks!

---

<div class="post-metadata">

**Author:** ![Tombo\_Meta](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@Tombo\_Meta](https://qa.fmod.com/u/Tombo_Meta)\
**Post date:** [April 26, 2024, 8:54pm UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/7 "2024-04-26T20:54:20Z")

</div>

Another update, migrated to another computer and the problem persists, that means it’s not machine dependent. Currently on FMOD Studio 2.02 and Unity 2022.3.5f1.

Why might the studio system not release correctly?

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [April 30, 2024, 5:41am UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/8 "2024-04-30T05:41:11Z")

</div>

> [@Tombo\_Meta](#):
>
> Why might the studio system not release correctly?

Something callback related would be my first guess - for example:

- Getting stuck in a user callback that is triggered when the system tries to release
- A user callback (typically with behavior that occurs when the system is releasing) not meeting the requirements set out in [the Callbacks section](https://www.fmod.com/docs/2.02/unity/user-guide.html#callbacks) of the FMOD for Unity user guide

If you’re using callbacks, especially those that would fire when the system is releasing, I would recommend making sure that the code there is safe and meets the requirements mentioned above.

Attempting to do something FMOD related (e.g. something like creating another system) from a different thread when the existing system is releasing may also cause issues. However, this is less likely unless you’ve modified the FMOD for Unity plugin heavily, or have a lot of your own custom editor code for interacting with FMOD.

---

<div class="post-metadata">

**Author:** ![Tombo\_Meta](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@Tombo\_Meta](https://qa.fmod.com/u/Tombo_Meta)\
**Post date:** [April 30, 2024, 4:57pm UTC](https://qa.fmod.com/t/fmod-waiting-for-user-code-in-fmodunity-dll-to-finish-executing/21260/9 "2024-04-30T16:57:54Z")

</div>

Thanks for the pointer!

While I can’t say for certain it was the cause (as it started magically not hanging again overnight), I can say that I indeed was forgetting to cache the callback delegate, and have implemented that in my code. I’ll report back if anything else changes, but I’ll consider it fixed for now. 👍
