SaladLab / Json.Net.Unity3D

Forked Newtonsoft.Json to support Unity3D
MIT License
918 stars 169 forks source link

JIT compile method #1

Closed rubentorresbonet closed 8 years ago

rubentorresbonet commented 8 years ago

Hey, thank you for your great work! My code runs great on PC but not on XBOne. The printed error:

ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.GenericEqualityComparer`1<Newtonsoft.Json.Serialization.DefaultSerializationBinder/TypeNameKey>:.ctor ()' while running with --aot-only.

at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod*,object,object[],System.Exception&) at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation. at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type) [0x00000] in :0 at System.Collections.Generic.EqualityComparer1[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey]..cctor () [0x00000] in <filename unknown>:0 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Collections.Generic.EqualityComparer1 at System.Collections.Generic.Dictionary2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type].Init (Int32 capacity, IEqualityComparer1 hcp) [0x00000] in :0 at System.Collections.Generic.Dictionary2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type]..ctor () [0x00000] in <filename unknown>:0 at Newtonsoft.Json.Utilities.ThreadSafeStore2[Newtonsoft.Json.Serialization.DefaultSerializationBinder+TypeNameKey,System.Type]..ctor (System.Func`2 creator) [0x00000] in :0 at Newtonsoft.Json.Serialization.DefaultSerializationBinder..ctor () [0x00000] in :0 at Newtonsoft.Json.Serialization.DefaultSerializationBinder..cctor () [0x00000] in :0 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Newtonsoft.Json.Serialization.DefaultSerializationBinder at Newtonsoft.Json.JsonSerializer.Create () [0x00000] in :0 at Newtonsoft.Json.JsonSerializer.Create (Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0 at Newtonsoft.Json.JsonSerializer.CreateDefault () [0x00000] in :0 at Newtonsoft.Json.JsonSerializer.CreateDefault (Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0 at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0 at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value) [0x00000] in :0 at SaveGame.UpdateFromGame (.Game game) [0x00000] in C:\dev\blackguards-1\Unity\Assets\Scripts\Utils\SaveGame.cs:92

Do you have any idea? Thank you again!

veblush commented 8 years ago

Thanks for reporting error. I'll take look at the case. Before my work, try adding link.xml to your project.

veblush commented 8 years ago

This problem is not reproducible with Unity 5.2 and IL2CPP build option. Dynamic code generation bug with this problem is rooted in mono-aot but mono-aot is replaced with unity-il2cpp now. So it's hard to see this problem again.

I want to know more detail of this problem.