How do I get rid of FMOD errors in the console: "An error occured that wasn't supposed to. Contact support."

I’ve run into a strange fmod-related audio bug with Unity Editor.

Upon opening Unity, the console emits this long set of errors(1) many, many times. This slows down opening the Editor significantly – but further, the repetitive errors are also emitted every time I Build a Player, making the process many minutes slower than usual.

This error briefly occurred last week, but simply sync’ing to an old changeset and then sync’ing back to the head revision caused it to go away.

However, the error’s back now, and isn’t consistently found at the same changeset – while head revision always seems to display the problem, sync’ing around to different changesets has (several times) shown that one changeset will on one sync display the problem, and on another sync won’t.

My teammates have not seen this bug; it’s only on my machine.

Here’s some possibly-relevant specs:

  • Unity 4.2.0f4
  • Fabric 2.1.7c
  • Windows 7
  • Echo Gina3G soundcard with driver revision 8.5

Other than iTunes (which I always have open), no other sound software is open. Restarting my PC doesn’t seem to make any difference.

Any ideas?

(1) Editor.log:

Validating Project structure … 0.106595 seconds.
Platform assembly: C:\Program Files (x86)\Unity\Editor\Data\Managed
unit.framework.dll (this message is harmless)
result == FMOD_OK

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 275)

An error occured that wasn’t supposed to. Contact support.

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 275)

result == FMOD_OK

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 281)

An error occured that wasn’t supposed to. Contact support.

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 281)

m_wetGroup

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 284)

m_dryGroup

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 285)

result == FMOD_OK

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 312)

An invalid object handle was used.

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 312)

result == FMOD_OK

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 315)

An invalid object handle was used.

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 315)

result == FMOD_OK

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 318)

An invalid parameter was passed to this function.

(Filename: C:/BuildAgent/work/cac08d8a5e25d4cb/Runtime/Audio/AudioSource.cpp Line: 318)

result == FMOD_OK

This ended up being a corrupt .unity file.

Even when I don’t knowingly make any change to an open .unity file, Unity often wants to save it with some opaque binary change. Up to this point, I’ve always “gone along with” Unity and submitted the “changed” .unity file to source control.

It appears that one of these “non-changes” corrupted the .unity file such that it demonstrated the above behavior. Simply rolling back to the previous change fixed the problem.

From now on, I plan to revert every .unity file that claims it is changed unless I really meant to change it.

I had the exact same issue (long repetition of exactly the same errors mentioned above). After much troubleshooting I discovered the solution for my situation:

I had a glitched prefab.

In my project, I have one root prefab that is duplicated over and over and the values are tweaked in the inspector. What I didn’t notice is that the prefab had begun to take on children in the Project tab that should not have been there. Moreover, every time I duplicated the prefab, another one of these phantom children objects would be added.

So the problem compounded. By phantom, I mean that while I could select the child objects in the Project window, I could NOT DELETE THEM (tried right clicking, hitting delete, nothing worked). When I dragged one of these prefabs directly into the scene, Unity would stall for a long time as it tried to figure out whether there was a child there or not. Finally, after a long list of errors, the object would indeed appear with children in my scene. At that point I could delete the child objects from the prefab in the hierarchy, and then apply the changes to the original prefab.

One last thing I’ll mention is that in my game I use a level editor to tweak the prefab public values. My level editor invokes ‘SetDirty’ to ensure changes to the prefab are saved. I imagine that somewhere during the SetDirty invocation the glitch happened.

I’ll post a bug report/solution to Unity.

I’m intentionally abusing the editor to do some profiling out of curiosity. I get this error or a crash with the following code.

void Start()
{
    double iterations = 5000.0;
    Debug.Log("***** Start");

    GameObject root = new GameObject("root");
    root.AddComponent<SpriteRenderer>();
    root.AddComponent<AudioSource>();
    root.AddComponent<Light>();
    GameObject latest = root;
    using (new Timer("new GameObject()", iterations ))
    {
        for(int i = 0; i < (int)iterations ; ++i)
        {
            var go = new GameObject();
            go.AddComponent<SpriteRenderer>();
            go.AddComponent<AudioSource>();
            go.AddComponent<Light>();
            go.transform.parent = latest.transform;
            latest = go;
        }
    }

    Destroy(root);

    root = new GameObject("root");
    root.AddComponent<SpriteRenderer>();
    root.AddComponent<AudioSource>();
    root.AddComponent<Light>();
    latest = root;

    using (new Timer("GameObject.Instantiate", iterations ))
    {
        for (int i = 0; i < (int)iterations ; ++i)
        {
            var go = Instantiate(latest) as GameObject;
            go.transform.parent = latest.transform;
            latest = go;
        }
    }

    Destroy(root);

    Timer.PrintAll();
}

For the curious, the timer used in this code is this:

class Timer : IDisposable
{
    private readonly string m_Text;
    private Stopwatch m_Stopwatch;
    private double m_DivBy;

    private static List<string> m_Backlog = new List<string>();

    public Timer(string text, double divBy = 0.0)
    {
        m_Text = text;
        m_DivBy = divBy;
        m_Stopwatch = Stopwatch.StartNew();
    }

    public void Dispose()
    {
        m_Stopwatch.Stop();
        if (m_DivBy != 0.0)
        {
            m_Backlog.Add(string.Format("Profiled {0}: {1} seconds. {2} milliseconds.", m_Text, m_Stopwatch.Elapsed.TotalSeconds / m_DivBy, m_Stopwatch.Elapsed.TotalMilliseconds / m_DivBy));
        }
        else
        {
            m_Backlog.Add(string.Format("Profiled {0}: {1} seconds. {2} milliseconds.", m_Text, m_Stopwatch.Elapsed.TotalSeconds, m_Stopwatch.Elapsed.TotalMilliseconds));
        }

    }

    public static void PrintAll()
    {
        foreach(var result in m_Backlog)
        {
            Debug.Log(result);
        }
    }
}

Running 5000 iterations causes this error to occur.

Running 10000 iterations is a 100% crash of the editor with no crash reporter.