-
Notifications
You must be signed in to change notification settings - Fork 131
Bug: [IL2CPP] ExecutionEngineException on deserializing array of struct #77
Comments
Hi @SergeOxe! Thanks for making such a clear issue! This is actually a known issue with the package, and I apologize for not being clear about it back. The issue here is about some AOT generation. Funny, I have written some wiki pages, a bit hidden, over 'ere: https://github.com/jilleJr/Newtonsoft.Json-for-Unity/wiki/Fix-AOT-compilation-errors, and in this case, I would suggest looking into using AotHelper. Especially the To fix this, you need to add using UnityEngine;
using Newtonsoft.Json.Utility;
public class AotEnforcements : MonoBehaviour
{
public void Awake()
{
AotHelper.EnsureList<NestedStruct>();
}
} Hope that resolves it for you! :) |
For reference, the reason it works when it's a The Unity engine already has some references to some In the background, a
Structs have this particular property of being embedded wherever they're used. For example, if we had the following struct: struct Vector2 {
public int x;
public int y;
} Then the memory of an
Because structs behaves like this, IL2CPP does not even try to reuse generic types where the generic type argument is a struct. More about this here: https://blogs.unity3d.com/2015/06/16/il2cpp-internals-generic-sharing-implementation/ |
@jilleJr Thanks for your quick response and detailed explanation! You are doing a great job 💪. I missed the wiki page, thanks! |
@SergeOxe Heh thanks :) I got into writing mood so may have written too much detail /shrug. Tell me if AotHelper fixed the problem! I do find joy in resolving these issues |
## [SDK-301](https://ready-player-me.atlassian.net/browse/SDK-301) ## Description - Added handling of expired refresh token - logs out user if refresh token expires - Fixed the blocking error on android #33 - fix found here applejag/Newtonsoft.Json-for-Unity#77 (comment) - Updated readme with supported platform - Adjusted loading popup ui according portrait mode
Expected behavior
Successfully deserializing json with array of nested struct.
{"classProp":"this is classProp Value", "myArray":[{"someProp":"someProp Value"}]}
Actual behavior
Getting ExecutionEngineException.
ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[MyClass+NestedStruct, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]::.cctor' for which no ahead of time (AOT) code was generated.
Steps to reproduce
jillejr.newtonsoft.json-for-unity
via UPMDetails
Please Note that if I changing the struct to class, it will work as expected.
Host machine OS running Unity Editor 👉 MacOS Catalina
Unity build target 👉 Android
Newtonsoft.Json-for-Unity package version 👉 12.0.301
I was using Unity version 👉 2018.4.26
Checklist
The text was updated successfully, but these errors were encountered: