MonoGame iOS IDictionary<Byte, T> crash

Hi - I’m new to the MonoGame community… I’ve been using MonoGame for quite some time and had some legacy code that worked fine on older version of MonoGame v3.5 when using IDictionary<Byte, T> where T may be Vector2 or Rectangle type.

However, after upgrading to MonoGame v3.7.1 this code causes iOS builds to crash on device with a nasty SIGABRT crash report. Here is the actual Native Crash Report message:
“Got a SIGABRT while executing native code. This usually indicates a fatal error in the mono runtime or one of the native libraries used by your application.”

I can confirm that the offending code uses IDictionary<Byte, Vector2> or IDictionary<Byte, Rectangle> because if I change the type of the key from Byte to Int16 or Int32 then the code works fine without crash. Therefore, it seems to be some issue with Byte type platform invoke to the corresponding native type of iOS for Mono.

Finally, please note that everything on the Mac is up-to-date - I have upgraded on Xcode 11.2 and the latest Mono framework MDK and Xamarin iOS installed.

Thanks,
Steven.

Does the crash happens if T, instead of Vector2 or Rectangle, is a structure of your own?

Thanks KakCAT1d - I only experienced the crash with T as Vector2 and Rectangle on iOS.
If I used my own structure / custom type e.g. Enemy object then that works fine…

To summarize, I scanned all my MonoGame code bases and the following work OK without crash on iOS:

IDictionary<Byte, UInt16>
IDictionary<Byte, IList<Single>>
IDictionary<Byte, Enemy> // custom type
IDictionary<Byte, Explosion> // custom type

I hope this helps!
Steven.

It’s weird. AFAIK MonoGame does not contain any code that could interfere with IDictionary (maybe only the hash function, which is probably X.hash * something + Y.hash). It’s probably a Xamarin problem (you should open an issue, either a monogame’s github or xamarin’s bug tracker)

Are Enemy,Explosion structs or classes? Maybe the bug only happens with structs.

Thanks KakCAT - yes those custom Enemy / Explosion types are classes not structs. BTW: I did a simple code test on Xamarin iOS directly to iOS device and the IDictionary<Byte, [struct]> worked without crash.

No idea, sorry. My bet would be a xamarin bug: there’s no reason for a C# program to crash with a SIGABORT unless using unsafe