ERR_INVALID_HANDLE, seemingly randomly on getSoundSize(out soundSize);

Hi guys, hoping for some help on this one. I’ve looked about the forum and through the documentation thoroughly but can’t find anything that might explain this one.

The basic problem is that when trying to getSoundSize of an EventInstance programmatically at runtime, FMOD will return an OK result with the correct value for sound size for some events, but for other events it returns 0 with the error code ERR_INVALID_HANDLE. I can’t figure out what constitutes a valid handle, as almost all of the data / playback information related to the two events is identical.

Needless to say, both events have a sound size setting (both set to user, and value 1.0 if you’re interested).

The affected instances are failing the ‘isValid’ check, but I can’t get any decent error information to find out why exactly it is failing. I want to run this code once, not every frame, so am trying to figure this error out.

The error is persistent and repeatable for the affected events, and other events can get the sound size value with no such error. It isn’t random.

Any ideas as to why some of my events will have an ‘invalid handle’?

Many thanks all

Hi,

ERR_INVALID_HANDLE is an error code that indicates that the underlying object has been destroyed. Since you’re working with EventInstance and EventDescription, it’s likely that you’ve done something that has caused a given EventInstance or EventDescription to be destroyed before calling Studio.EventDescription.getSoundSize().

It’s impossible to diagnose what the issue specifically is without seeing your code, but a common cause of this would be calling Studio.EventInstance.release() on an instance, thereby flagging it for destruction when playback stops, and then after playback has stopped calling Studio.EventInstance.getSoundSize() on the destroyed instance.

1 Like

Thanks Louis. I haven’t called .release or destroyed the object, but you might have pointed me in the right direction anyway. The sounds aren’t virtual, and aren’t in audible range when calling the function. Could that be it? About to test that theory now.

I think some scene optimization was to blame (keeping assets unloaded even after initialization)

This little loop called in Update has fixed it

    // check if sound is valid before attempting to get soundsize
    if (EventInstance.isValid() && SoundSizeSet == false)
    {
        ed.getSoundSize(out SoundSize);
        SoundSizeSet = true;
        FMOD.RESULT result = EventInstance.getDescription(out ed);
     }