FMod 2.01 Callback freeze

Ive been trying to implement a callback into my unity game - but my current implementation freezes the editor at the time of execution.
Reading examples in the documentation/forum havent been of help, as it looks like i’m doing everything correctly. Otherwise, its pretty difficult to debug a freeze…

    private void MyOneShot(string path, string parameterName, int parameterValue, Vector3 position)
    {
        var instance = RuntimeManager.CreateInstance(path);
        annaInstance = instance;
        Singleton.instance.pauMen.instancesToPause.Add(instance);

        annaInstance.set3DAttributes(RuntimeUtils.To3DAttributes(position));

        stopUpdatingPos = true;
        updatingPosCR = StartCoroutine(KeepUpdatingPos());

        annaInstance.setParameterByName(parameterName, parameterValue);

        if (parameterValue == 49)//shrink end verify. sorry j
        {
            shrinkEndCallback = new EVENT_CALLBACK(EndEventCallback);
            annaInstance.setCallback(shrinkEndCallback, EVENT_CALLBACK_TYPE.SOUND_STOPPED);
            print("idkmeng");
        }

        annaInstance.start();
        annaInstance.release();
    }

    [AOT.MonoPInvokeCallback(typeof(EVENT_CALLBACK))]
    static RESULT EndEventCallback(EVENT_CALLBACK_TYPE type, IntPtr instance, IntPtr parameterPtr)
    {


        switch (type)
        {
            case EVENT_CALLBACK_TYPE.SOUND_STOPPED:
                {

                    Singleton.instance.SuddenCredits();
                    print("hello");
                    break;
                }
        }

        return RESULT.OK;
    }
}

Hi,

Unfortunately, 2.01 is no longer supported. Would it be possible to update to 2.02 and test if the issue is still present?

Hi, Connor! Thank you for responding.

Unfortunately i am five days away from my game’s launch, and so i imagine you can understand why updating such a core thing at a moment like this would be… unwise. Still, using an unsupported version of FMOD wouldn’t mean this simply doesn’t work, right?
Anyway, i’ve been able to temporarily mitigate my problem without using the FMOD api. In case i can’t be assisted due to the version i’m using, i intend on returning to this topic in the near future, after i update.

1 Like

Hi,

I see, running your code in 2.01 I was not able to reproduce the issue. I will link to our Unity Integration | Scripting Examples - Timeline Callbacks which also uses an event callback and may be a useful reference.

Do you know how far into the code you are getting before it is freezing? Something I notice that may be causing issues is accessing the Singleton inside the callback. Callbacks can be called from different threads depending on some init flags, further explained here: FMOD Engine - Studio Guide - Event Callback. If you comment out that line do you find the issue continues?

1 Like

Spot on, commenting that out gets rid of the freeze and logs the message.
You mentioned some init flags. How can i change those flags? Does changing them affect anything other than callback behavior?

1 Like

Hi, good to hear that solved it.

On line 288 in the RuntimeManager.cs class in the plugin directory, you can change the init flags and add any you want from this list: FMOD Engine | Studio API Reference - FMOD_STUDIO_INITFLAGS.

Each flag will only affect their systems e.g. the DEFFERED_CALLBACK will only change how the callbacks behave, the list above will explain each of their behaviors.

Hope this helps!

1 Like

It helps! I switched it up like this:

            FMOD.Studio.INITFLAGS studioInitFlags = FMOD.Studio.INITFLAGS.NORMAL | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE;//FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS;

No freezing, method is called as normal. I have not noticed any other difference.
Thank you, Connor! I’m used to not getting any help in forums like these, so this is a pleasant surprise. I wish you a fantastic week!

1 Like

That is good to hear and my absolute pleasure!

If you have any more questions please do not hesitate to ask!

1 Like