com.openai.unity: iOS: JsonSerializationException: Cannot deserialize readonly or fixed size dictionary: System.Collections.Generic.IReadOnlyDictionary
Having exception with serialization metadata on iOS, works in Unity Editor and Android.
Unity 2022.3.14f Managed stripping level: Minimal
I believe the issue is with stripping backend which is il2cpp for iOS and Mono for Android. Somehow, on iOS doesn’t support serialization of:
[Preserve]
[JsonProperty("metadata")]
public IReadOnlyDictionary<string, string> Metadata { get; }
Tried to pass null, empty Dictionary, both didn’t work
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Comments: 22 (13 by maintainers)
That’s working now, great work. thx
Great I’ll push out that release now.
This one works on iOS:
Don’t know if I can deal with these screenshots 😅 Any chance you can paste the actual text?
I managed to reproduce issue and created test class for it, on iOS JsonConvert.DeserializeObject for IReadOnlyDictionary doesn’t work, probably should be replaced with Dictionary<string, string>.
Here is test class:
With Test1 click having the same error:
I’m unfamiliar with iOS but it definitely seems as though a type is getting stripped from the build somehow.
Let me know what you can find and I’ll implement a fix if possible.
Thank you Stephen for fast response. Yes, I tried different types, the whole OpenAI namespace, it didn’t work out. I think the issue is not with stripping but with deserialization IReadOnlyDictionary itself. It can’t deserialise metadata but somehow works fine on Android. I will try to make a build for Android with il2cpp and check if the issue reproduces.