JIT compiler invoked when deserializing story on iOS
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 540
- PR merge metrics
- No merged PRs in 30d
Description
This is for version 0.2.3 alpha.
I had not tested on device for some time, so not quite sure when this started happening. I fully realize that this is more an issue with the NewtonSoft.JSON dll than it is with the Inkle library, but seeing as how you publish on iOS as well I thought it worth a mention :-)
I can provide the JSON string for the story, or a more complete example if you want, but I think this will be easily reproducible.
```
running tests...InkTests
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
FAILED: LoadTestFile
(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
reason: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: An exception was thrown by the type initializer for Newtonsoft.Json.Utilities.ConvertUtils ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Collections.Generic.EqualityComparer`1 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.GenericEqualityComparer`1:.ctor ()' while running with --aot-only.
at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
--- End of inner exception stack trace ---
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.EqualityComparer`1[Newtonsoft.Json.Utilities.ConvertUtils+TypeConvertKey]..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at System.Collections.Generic.Dictionary`2[Newtonsoft.Json.Utilities.ConvertUtils+TypeConvertKey,Newtonsoft.Json.Serialization.Func`2[System.Object,System.Object]].Init (Int32 capacity, IEqualityComparer`1 hcp) [0x00000] in :0
at System.Collections.Generic.Dictionary`2[Newtonsoft.Json.Utilities.ConvertUtils+TypeConvertKey,Newtonsoft.Json.Serialization.Func`2[System.Object,System.Object]]..ctor () [0x00000] in :0
at Newtonsoft.Json.Utilities.ThreadSafeStore`2[Newtonsoft.Json.Utilities.ConvertUtils+TypeConvertKey,Newtonsoft.Json.Serialization.Func`2[System.Object,System.Object]]..ctor (Newtonsoft.Json.Serialization.Func`2 creator) [0x00000] in :0
at Newtonsoft.Json.Utilities.ConvertUtils..cctor () [0x00000] in :0
--- End of inner exception stack trace ---
at Newtonsoft.Json.Linq.JToken.ToObject (System.Type objectType) [0x00000] in :0
at Newtonsoft.Json.Linq.JToken.ToObject[Int32] () [0x00000] in :0
at Ink.Runtime.Story..ctor (System.String jsonString) [0x00000] in :0
at LiveSequenceManager.LoadStory (System.String storyName) [0x00016] in /Users/jonathanculp/Documents/Guildlings/Assets/Scripts/Ink/LiveSequenceManager.cs:104
at InkTests.LoadTestFile () [0x00000] in /Users/jonathanculp/Documents/Guildlings/Assets/Scripts/Testing/Tests/Ink/InkTests.cs:62
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in :0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in :0
at UnitTestHarness.RunTest (System.Reflection.MethodInfo info) [0x0000f] in /Users/jonathanculp/Documents/Guildlings/Assets/Scripts/Testing/Framework/UnitTestHarness.cs:38
```
Some of that trace - specific to my project obviously, but I believe I've properly isolated the cause to just the provided Inkle libraries. I'm definitely not ruling out the possibility that the problem is on my end.
I don't have the best understanding of when or how the JIT compiler is invoked. But I do remember this having worked on previous versions. I'll start reviewing the changes.
Out of curiosity whats the source of your Newtonsoft.Json.dll? I remember that the mono version of this assembly had many compatibility issues with iOS. Many unity users will be using a ported version of this assembly from the asset store that was written specifically to be more compatible with iOS's AOT restrictions. It forked quite a long time ago, so it's more than a few versions behind the official Newtonsoft project. Despite that, for many of us, its a better choice.
-Jonathan
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.