[BUG] If stop is called twice, Unity shuts down without any error logs

static FMOD.RESULT FmodEventCallback(FMOD.Studio.EVENT_CALLBACK_TYPE type, IntPtr instancePtr, IntPtr parameterPtr)
{
switch (type)
{
    case FMOD.Studio.EVENT_CALLBACK_TYPE.SOUND_PLAYED:
        {
            FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);

            if (!instance.isValid())
                break;

            var result = instance.getPlaybackState(out var state);
            if (result == FMOD.RESULT.OK && state == FMOD.Studio.PLAYBACK_STATE.PLAYING)
            {
                instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
            }
            break;
        }
}
}

In a specific situation where there were dozens of sound instances are playing, a looping music event was stopped externally, but some of the sounds would not stop no matter what. So, I tried checking in the callback and forcefully calling stop.

However, when using it this way, if stop is called twice, Unity forcefully crashes every time without any warning.

Please look into this.

The code shown above was just a simplified example.
In the actual implementation, there are additional triggers involved.
I’ve already tried safely ensuring that stop is called only once,
but the music can still be heard in some cases.

So when I try to forcefully call stop one more time,
Unity crashes immediately without fail.

Please investigate this issue.

case FMOD.Studio.EVENT_CALLBACK_TYPE.SOUND_PLAYED:
    {
        FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);

        if (!instance.isValid() || !fmodMap.ContainsKey(instance))
            break;

        if (!fmodMap[instance].loop && 
            !fmodMap[instance].isPlaying &&
            fmodMap[instance].IsStopTriggered(instance))
        {
            var result = instance.getPlaybackState(out var state);
            if (result == FMOD.RESULT.OK && state == FMOD.Studio.PLAYBACK_STATE.PLAYING)
            {
                instance.stop(FMOD.Studio.STOP_MODE.IMMEDIATE/* AllowFadeout ? FMOD.Studio.STOP_MODE.ALLOWFADEOUT : FMOD.Studio.STOP_MODE.IMMEDIATE*/);
                fmodMap[instance].SetStopTrigger(instance, false);
            }
        } 

        break;
    }

The music is still audible, and when I check the state, it is
state == FMOD.Studio.PLAYBACK_STATE.PLAYING.

If I then try to call stop, Unity crashes immediately.
Why does calling stop more than once cause Unity to shut down?

Please review the internal FMOD code to ensure that repeated stop calls during playback do not crash Unity.
If a sound is still playing, the stop function should safely handle the call and exit gracefully, not crash the application.

A crash like this proves that the FMOD core is entering an invalid or unstable state.

state == FMOD.Studio.PLAYBACK_STATE.PLAYING

If there is a safer and more reliable function to forcefully stop a sound, please let me know.
I have confirmed through multiple state checks that the instance is in the SOUND_PLAYED state, yet when I call stop, Unity crashes.

Despite verifying that all status functions indicate it is clearly in the PLAYING state, calling stop still causes Unity to terminate.

If there’s a lower-level or more robust method to guarantee a sound is stopped without causing instability, I would appreciate it if you could point it out.

I am adding some additional information I confirmed.

In the case of the SOUND_PLAYED instance:

FMOD.Studio.EventInstance instance = new FMOD.Studio.EventInstance(instancePtr);

At this point, instancePtr has the pointer address 0x345000.

instance.isValid() returns true, and the playback state is PLAYBACK_STATE.PLAYING.

The stop function has already been called once,
but the state remains in “play”, the debug shows real = 1, and the sound is still playing.

Additionally, if I run the stop function again after several seconds,
Unity crashes immediately and forcibly shuts down.

If I skip the stop() call and instead run:

instance.release();
instance.clearHandle();

then instance.isValid() immediately returns false.

However, when the next callback message comes in,
instancePtr is still 0x345000, instance.isValid() is true, and it remains in the playing state.
The sound never actually stops!

This sound is being played in 3D with looping enabled.

Is there really no way for me to stop this sound?

The reason I’m pointing out this issue is because the loop sound that never stops continues to accumulate over time while the game is running.

If the number of these sounds exceeds the virtual channel limit, no other sounds will play correctly.
This is expected behavior from FMOD’s perspective — because those loop sounds are still occupying channels — but it’s also a critical issue, effectively a bug.

Even after calling stop(), the sound continues playing.
As I previously mentioned, calling instance.release() and instance.clearHandle() makes isValid() return false, but the callback still receives a valid instancePtr with isValid() == true and PLAYBACK_STATE.PLAYING.

This looped 3D sound simply refuses to stop.

Please provide a clear solution or workaround.
As of now, the sound still does not stop, and it causes the system to run out of available channels over time.

Hi,

Thank you for all the information and the code.

Unfortunately, I was not able to reproduce the issue.

Are you able to create a stripped out Unity project and upload it to your profile? The FMOD project with the following settings would be graet too:


Could I please grab your FMOD version:

Would it also be possible to add an result to the instance.stop() function to check it is not failing? If you enable the following:


And share the full logs:

If possible, a profiler session (FMOD Studio | Profiler) would be great too!