# Visual Studio freezes when debugging with FMOD installed

**URL:** <https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909>\
**Category:** Unity\
**Created:** [May 29, 2018, 11:36pm UTC](https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909 "2018-05-29T23:36:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![facaelectrica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/facaelectrica/32/105_2.png) [@facaelectrica](https://qa.fmod.com/u/facaelectrica)\
**Post date:** [May 29, 2018, 11:36pm UTC](https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909/1 "2018-05-29T23:36:05Z")

</div>

If I enable debugging with Visual Studio + Unity (2017), the moment I hit a breakpoint, Unity freezes and I have to do a forced restart. If I delete FMOD from the project everything works fine.

I found this piece of information in the VS documentation that MIGHT be the way to fix it:

> **[Troubleshoot Visual Studio Tools for Unity](https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/troubleshooting/troubleshooting-and-known-issues-visual-studio-tools-for-unity)**
>
> Troubleshoot Visual Studio Tools for Unity, review known issues and solutions for connections, program execution, project compatibility, debugging, and IntelliSense.

> Several Unity plugins like Parse, FMOD, UMP (Universal Media Player), ZFBrowser or Embedded Browser are using native threads. It’s an issue when a plugin ends up attaching a native thread to the runtime, which then does blocking calls to the OS. This means Unity can’t interrupt that thread for the debugger (or domain reload) and hang.

> For FMOD, there is a workaround, you can pass FMOD\_STUDIO\_INIT\_SYNCHRONOUS\_UPDATE initialization flag to disable asynchronous processing and perform all processing on the main thread.

Unfortunately, I have no idea where in my code I should be setting up the FMOD\_STUDIO\_INIT\_SYNCHRONOUS\_UPDATE flag…

So if that is the issue :

1. How do I change that flag during initialization (when is that exactly?)?
2. What is the right way to pass the value using the `FMOD.Studio.System.initialize()`?

And if the issue is something different, any suggestions/help?

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [May 31, 2018, 5:07am UTC](https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909/2 "2018-05-31T05:07:47Z")

</div>

Unfortunately this has been an issue for some time now when trying to debug native callbacks.

You can add that flag to the studioInitFlags found in the RuntimeManager.cs Initialize().

```
FMOD.Studio.INITFLAGS studioInitFlags = ... | FMOD_STUDIO_INIT_SYNCHRONOUS_UPDATE;
```

---

<div class="post-metadata">

**Author:** ![facaelectrica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/facaelectrica/32/105_2.png) [@facaelectrica](https://qa.fmod.com/u/facaelectrica)\
**Post date:** [June 20, 2018, 6:12pm UTC](https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909/3 "2018-06-20T18:12:50Z")

</div>

Kinda what I suspected, thanks @Cameron. This is what I ended up doing so it works in the editor and I can still have it work in a exported build:  
`  
FMOD.Studio.INITFLAGS studioInitFlags;

```
#if UNITY_EDITOR
//FIX FOR CRASHES
studioInitFlags = FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE;
#else
//ORIGINAL LINE
studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
#endif
`

```

I wonder if it will ever be properly fixed…

---

<div class="post-metadata">

**Author:** ![altmat](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@altmat](https://qa.fmod.com/u/altmat)\
**Post date:** [November 21, 2018, 5:37pm UTC](https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909/4 "2018-11-21T17:37:33Z")

</div>

> [@](#):
>
> Kinda what I suspected, thanks @Cameron. This is what I ended up doing so it works in the editor and I can still have it work in a exported build:  
> `  
> FMOD.Studio.INITFLAGS studioInitFlags;
> 
> ```
> #if UNITY_EDITOR
> //FIX FOR CRASHES
> studioInitFlags = FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE;
> #else
> //ORIGINAL LINE
> studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;
> #endif
> `
> 
> ```
> 
> I wonder if it will ever be properly fixed…

Wow, thanks for this question and answer here. I’ve lost a whole day just trying to find what was wrong, until I realized we only had this issue on scenes where there was music going on. Changing this flag solved the problem for us too.

---

<div class="post-metadata">

**Author:** ![facaelectrica](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/facaelectrica/32/105_2.png) [@facaelectrica](https://qa.fmod.com/u/facaelectrica)\
**Post date:** [January 19, 2019, 10:08pm UTC](https://qa.fmod.com/t/visual-studio-freezes-when-debugging-with-fmod-installed/13909/5 "2019-01-19T22:08:09Z")

</div>

For future reference, if using the latest Unity version (2018.2.xx), since the code changed slightly, this is the line I now add to the RuntimeManager.cs:

```
#if UNITY_EDITOR
	//FIX FOR CRASHES
	studioInitFlags = FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE;
#endif

```

It should go right after this line, under the **Initialize()** method:

`FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;`
