Unity Silently crashes when calling Channel.SetPaused

Hello,
I am creating FMOD events during runtime and mostly use the api to play stuff.
After a while triggering multiple sounds we sometimes run into a silent crash. This is the stack trace.

It seems like the channel I just created is invalid. How is that possible? I was thinking maybe because of too many real voices or virtual voices stealing eachother the channel. Is that possible?

at <unknown> <0xffffffff>
at FMOD.Channel:FMOD5_Channel_SetPaused <0x0009b>
at FMOD.Channel:setPaused <0x0002a>
0x00007ffe503ebd27 (fmodstudioL) FMOD_System_Update
0x00007ffe5031afaa (fmodstudioL) FMOD::ChannelControl::stop
0x00007ffe503eed1e (fmodstudioL) FMOD_System_Update
0x00007ffe503edfcf (fmodstudioL) FMOD_System_Update
0x00007ffe50317377 (fmodstudioL) FMOD::ChannelControl::setPaused
0x0000025205ff580c (Mono JIT Code) (wrapper managed-to-native) FMOD.Channel:FMOD5_Channel_SetPaused (intptr,bool)
0x0000025205ff573b (Mono JIT Code) [fmod.cs:2224] FMOD.Channel:setPaused (bool) 

That is the code we are triggering it with.

        FMOD.System system = FMODUnity.RuntimeManager.CoreSystem;

            if (parentGroup.hasHandle())
            {
                system.playSound(_sound, parentGroup, true, out Channel activeChannel);
                if (activeChannel.hasHandle())
                {
                    _activeChannel = activeChannel;
                    _activeChannel.setPaused(false);
                    _startedPlaying = true;
                }
            }

Hi,

Thanks for the code and the stack trace - I’ve done some testing one my end using the provided information, but I wasn’t able to reproduce the issue. If possible, could I get you to upload your Unity project/build (or a stripped down version) where you can consistently reproduce the issue to your FMOD profile for me to take a look at?

A few additional questions:

  • What version of Unity and FMOD for Unity are you using?
  • Do you experience the crash in editor, development builds (using logging libs), release builds (using release libs), or some combination of the three?
  • If you set the logging level to “Log” and enable API error logging in the Initialization section of FMOD Unity’s settings, do you receive any additional info? Since you’re getting a silent crash, you will need to grab the log from Unity’s log directories.

Hello,
I dont think i am allowed to upload the project, but I could ask the producer if you could get access to the project perforce if that would help? Also do we want to move the communication to some slack channel or is email better for you?
Im also unable to repro that issue, which makes it pretty hard to debug for me.
Unity 2021.3.16f1
FMOD 2.02.15

I was reported it appears in Builds and in editor.
I just tried the Log and I get a bunch of ERR_INVALID_HANDLE where im checking for hasHandle right before. Plus some channel stolen messages, but I believe they wont be fatal right?
I will communicate to our tester to switch on the additional Logging and will try to get some more information from there.
Kind regards Jonas

Is it possible that the Channel gets stolen between creation, which is paused by default and the unpause call?

Access to a project perforce works, but it’s more committal on our end compared to just uploading a project. Since there’s not a solid repro, it’s probably better to put project access to the side until I have some more info from you.

If email is more suitable for you, then that would work fine - you can email support@fmod.com and include a link to this forum post, and we’ll go from there.

It’s unlikely to be the cause of a crash - if a channel is stolen, or the sound it is playing released, it should simply return ERR_INVALID_HANDLE instead of crashing. The “channel stolen” messages aren’t fatal.

A few more questions:

  • How are you creating your _sound object? For example, what flags and FMOD_CREATESOUNDEXINFO options are you using, if any?
  • Regarding your second callstack snippet, the stack appears to be corrupted - FMOD::ChannelControl::setPaused doesn’t call into FMOD_System_Update, so unless this is list of FMOD functions that are called in chronological order, I would recommend trying to get a crash stack from a development build to see whether that can provide more accurate info.
  • Are you calling any other FMOD functions from other threads? For example, anything to do with the Sound assigned to _sound, or RuntimeManager’s system, like updating, creating, or releasing the system?

Just following up on this - are you still running into the crash on Channel.SetPaused? If so, could I get you to answer the questions in my previous reply so I have some more information regarding the issue?

Hello,
no, the issue was that the sound that was input into the createSound was already released, but returned Ok and crashed after a certain time and just put setPaused at the end of the callstack.

Kind regards Jonas

Happy to hear that you managed to resolve the issue - feel free to get in touch if you run into any further problems.