# Crash with programmer sounds on PS4

**URL:** <https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460>\
**Category:** Unity\
**Created:** [September 22, 2017, 4:16pm UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460 "2017-09-22T16:16:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pelle/32/79_2.png) [@Pelle](https://qa.fmod.com/u/Pelle)\
**Post date:** [September 22, 2017, 4:16pm UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460/1 "2017-09-22T16:16:36Z")

</div>

Hi all,  
We are trying to make our project (that is running smoothly on PC) works on PS4. We are working with Unity 5.5.4p5 and FMOD 1.10.  
The problem occurs when we receive a programmer sound callback. We have managed to track down the line that is making the game crash on PS4:

```
var soundResult = FMODUnity.RuntimeManager.LowlevelSystem.createSound (
dialogueSoundInfo.name_or_data, dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out dialogueSound);

```

In the PS4 Console Output we get this error:

```
C:/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/PlatformInvoke.cpp(382) : 
Assertion Failed (d->method->methodDefinition) in function MarshalDelegate

```

This is the whole callback code:

```
[AOT.MonoPInvokeCallback (typeof(FMOD.Studio.EVENT_CALLBACK))]
private static FMOD.RESULT DialogueEventCallback(
	FMOD.Studio.EVENT_CALLBACK_TYPE type,
	FMOD.Studio.EventInstance instance, IntPtr parameterPtr)
{ // Retrieve the user data
	IntPtr stringPtr;
	instance.getUserData (out stringPtr);

	// Get the string object
	GCHandle stringHandle = GCHandle.FromIntPtr (stringPtr);
	String key = stringHandle.Target as String;

	switch (type)
	{
	case FMOD.Studio.EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
		FMOD.Studio.SOUND_INFO dialogueSoundInfo;

		var parameters = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure (parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));
		var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo (key, out dialogueSoundInfo);
		if (keyResult != FMOD.RESULT.OK)
		{
			break;
		}

		FMOD.Sound dialogueSound;
		var soundResult = FMODUnity.RuntimeManager.LowlevelSystem.createSound (dialogueSoundInfo.name_or_data, dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out dialogueSound);
		if (soundResult == FMOD.RESULT.OK)
		{
			parameters.sound = dialogueSound.handle;
			parameters.subsoundIndex = dialogueSoundInfo.subsoundindex;
			Marshal.StructureToPtr (parameters, parameterPtr, false);
		}
		break;
	[...]
}

```

I can’t understand what we are doing wrong and if it’s a problem related to how we have implemented programmer sound.

Thanks for your support,  
Simone

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [September 27, 2017, 1:44am UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460/2 "2017-09-27T01:44:56Z")

</div>

> [@](#):
>
> Hi all,  
> We are trying to make our project (that is running smoothly on PC) works on PS4. We are working with Unity 5.5.4p5 and FMOD 1.10.  
> The problem occurs when we receive a programmer sound callback. We have managed to track down the line that is making the game crash on PS4:
> 
> ```
> var soundResult = FMODUnity.RuntimeManager.LowlevelSystem.createSound (
> dialogueSoundInfo.name_or_data, dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out dialogueSound);
> 
> ```
> 
> In the PS4 Console Output we get this error:
> 
> ```
> C:/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/PlatformInvoke.cpp(382) : 
> Assertion Failed (d->method->methodDefinition) in function MarshalDelegate
> 
> ```
> 
> This is the whole callback code:
> 
> ```
> [AOT.MonoPInvokeCallback (typeof(FMOD.Studio.EVENT_CALLBACK))]
> private static FMOD.RESULT DialogueEventCallback(
> FMOD.Studio.EVENT_CALLBACK_TYPE type,
> FMOD.Studio.EventInstance instance, IntPtr parameterPtr)
> { // Retrieve the user data
> IntPtr stringPtr;
> instance.getUserData (out stringPtr);
> 
> // Get the string object
> GCHandle stringHandle = GCHandle.FromIntPtr (stringPtr);
> String key = stringHandle.Target as String;
> 
> switch (type)
> {
> case FMOD.Studio.EVENT_CALLBACK_TYPE.CREATE_PROGRAMMER_SOUND:
> FMOD.Studio.SOUND_INFO dialogueSoundInfo;
> 
> var parameters = (FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES)Marshal.PtrToStructure (parameterPtr, typeof(FMOD.Studio.PROGRAMMER_SOUND_PROPERTIES));
> var keyResult = FMODUnity.RuntimeManager.StudioSystem.getSoundInfo (key, out dialogueSoundInfo);
> if (keyResult != FMOD.RESULT.OK)
> {
> break;
> }
> 
> FMOD.Sound dialogueSound;
> var soundResult = FMODUnity.RuntimeManager.LowlevelSystem.createSound (dialogueSoundInfo.name_or_data, dialogueSoundInfo.mode, ref dialogueSoundInfo.exinfo, out dialogueSound);
> if (soundResult == FMOD.RESULT.OK)
> {
> parameters.sound = dialogueSound.handle;
> parameters.subsoundIndex = dialogueSoundInfo.subsoundindex;
> Marshal.StructureToPtr (parameters, parameterPtr, false);
> }
> break;
> [...]
> }
> 
> ```
> 
> I can’t understand what we are doing wrong and if it’s a problem related to how we have implemented programmer sound.
> 
> Thanks for your support,  
> Simone

Does this only occur in development builds or release builds too?

---

<div class="post-metadata">

**Author:** ![Pelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pelle/32/79_2.png) [@Pelle](https://qa.fmod.com/u/Pelle)\
**Post date:** [September 29, 2017, 9:09am UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460/3 "2017-09-29T09:09:02Z")

</div>

This occurs in both development and release builds.  
I’ve just tested a release build and i get the same error:  
C:/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/PlatformInvoke.cpp(382) : Assertion Failed (d-\>method-\>methodDefinition) in function MarshalDelegate

---

<div class="post-metadata">

**Author:** ![Pelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pelle/32/79_2.png) [@Pelle](https://qa.fmod.com/u/Pelle)\
**Post date:** [September 29, 2017, 9:09am UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460/4 "2017-09-29T09:09:09Z")

</div>

This occurs in both development and release builds.  
I’ve just tested a release build and i get the same error:  
C:/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/vm/PlatformInvoke.cpp(382) : Assertion Failed (d-\>method-\>methodDefinition) in function MarshalDelegate

---

<div class="post-metadata">

**Author:** ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)\
**Post date:** [October 2, 2017, 3:51am UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460/5 "2017-10-02T03:51:56Z")

</div>

We are still investigating this on our end, so far we are only able to reproduce this on PS4 which leads us to believe it is an issue with PS4 and Mono.

One way to avoid this is to use the IL2CPP scripting backend, which can be changed in the Unity Player Settings menu. Using this then does not require the ‘MonoPInvokeCallback’ before the function.

The other option is to use SYNCHRONOUS\_UPDATE when initializing FMOD.Studio, this will disable asynchronous processing and perform all processing on the calling thread instead.  
More information about the FMOD Threading modes can be found here:  
[https://www.fmod.org/docs/content/generated/overview/studio\_thread.html](https://www.fmod.org/docs/content/generated/overview/studio_thread.html)

---

<div class="post-metadata">

**Author:** ![Pelle](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/pelle/32/79_2.png) [@Pelle](https://qa.fmod.com/u/Pelle)\
**Post date:** [October 2, 2017, 1:17pm UTC](https://qa.fmod.com/t/crash-with-programmer-sounds-on-ps4/13460/6 "2017-10-02T13:17:35Z")

</div>

> [@](#):
>
> We are still investigating this on our end, so far we are only able to reproduce this on PS4 which leads us to believe it is an issue with PS4 and Mono.
> 
> One way to avoid this is to use the IL2CPP scripting backend, which can be changed in the Unity Player Settings menu. Using this then does not require the ‘MonoPInvokeCallback’ before the function.
> 
> The other option is to use SYNCHRONOUS\_UPDATE when initializing FMOD.Studio, this will disable asynchronous processing and perform all processing on the calling thread instead.  
> More information about the FMOD Threading modes can be found here:  
> [https://www.fmod.org/docs/content/generated/overview/studio\_thread.html](https://www.fmod.org/docs/content/generated/overview/studio_thread.html)

I alredy tried using both Mono and IL2CPP. I tried removing ‘MonoPInvokeCallback’ in IL2CPP and we got this error:

“NotSupportedException: To marshal a managed method, please add an attribute named ‘MonoPInvokeCallback’ to the method definition. at FMOD.Studio.EventInstance.FMOD\_Studio\_EventInstance\_SetCallback (IntPtr \_event, FMOD.Studio.EVENT\_CALLBACK callback, EVENT\_CALLBACK\_TYPE callbackmask)”.

I tried the other solution to. Not sure where to define SYNCHRONOUS\_UPDATE. I’ve put 'FMOD\_STUDIO\_INIT\_SYNCHRONOUS\_UPDATE ’ in the PlayerSettings but didn’t work, so I added this command

“studioInitFlags |= FMOD.Studio.INITFLAGS.SYNCHRONOUS\_UPDATE;”

at the script RuntimeManager.cs at line 202, but didn’t work either. The error is always the one that I’ve put in the first post.
