Programmer Sound freezes Unity (Unity 2022.2.1f1 / FMOD Unity 2.02.11)

Hi everyone!

I’m experiencing an issue with Programmer Sounds in Unity that I just can’t figure out. I have programmer sounds implemented in my application and it has worked perfectly until today. None of my recent code changes are in any way related to audio, so I’m really at a loss. I did update Unity to 2022.2.1f1 a few days ago, but it all still worked afterwards.

To rule out my own code, I’m using the 2.02 Programmer Sound example (https://www.fmod.com/docs/2.02/unity/examples-programmer-sounds.html) verbatim.

I can launch my application in play mode and hear other FMOD (non-programmer) sounds without issue, but as soon as the first programmer sound is played, Unity freezes.

Using the debugger, I was able to pin point that this is the line causing the freeze:

var soundResult = FMODUnity.RuntimeManager.CoreSystem.createSound(Application.streamingAssetsPath + "/" + key, soundMode, out dialogueSound);

Things I’ve tried without success:

  • Ensure that the path + key resolve to a proper file name that actually exists
  • Ensure that the audio file is not broken (I’ve swapped it out for a file that I confirmed works as a non-programmer sound)
  • Ensure that the audio file can be played back in FMOD Studio
  • Re-building in FMOD Studio
  • Updating FMOD Unity
  • Re-Installing FMOD Unity
  • Updating FMOD Studio
  • Playing only the programmer sound with no other sound playing
  • Rebooting my computer

The issue coincided with a warning that appears when opening Unity:

“Settings instance has not been initialized. Unable to continue build.”

I have not seen this message before, but may have previously missed it.

When I go to the “FMOD → Edit Settings” menu, the settings are opened. I also verified that there is also only one settings file.

I don’t get any other error messages beyond that, so I’m really not sure how I could identify the cause of this issue. Any help would be greatly appreciated!

Many thanks in advance!

Okay, it gets weirder…

After posting I realized that I never stepped into the call for “createSound” because I had assumed it was just a p/invoke call. Stepping into it, I realized that the crash did not in fact happen in “createSound” itself, but in the call to the static getter “RuntimeManager.CoreSystem”. This in turn calls “Instance”, another static getter in the RuntimeManager. So I stepped through that and the crash happens precisely in line 122 of RuntimeManager.cs:

if (!Application.isPlaying)

If I set a breakpoint on that line, I can see that it gets called a whole bunch of times without issue… the moment the programmer sound event callback calls it though, it’s game over. If I had to guess, I would say it’s because the event callback is running on another thread.

If I comment out this line, all my programmer sounds work again without freezing…

Unless I’m missing something, I believe this to be a bug. Any suggestions would be greatly appreciated.

1 Like

Hi,

The Unity editor freezing in this case is a known issue - a simple workaround is indeed to do as you’ve described and comment out the if statement.