The benefits of Unity's cross-platform release are obvious. But there are still some pits. Especially on iOS real-world. The problem with JIT is still tricky.
And it's good in unity and simulator, and it's going to be a problem running on the real machine.
When you run into
Executionengineexception:attempting to JIT compile method ' ... ' while running with--aot-only.
error. Description There is code used Jit. But in the iOS platform, Mono is a that runs in full AOT mode; This exception was thrown because the JIT engine could not be used.
Mono's AOT, like the. NET NGen, reduces JIT work by compiling ahead of time, but by default the AOT does not compile all IL code, but rather a balance between optimization and JIT. Because the iOS platform disables JIT compilation, Mono requires full AOT compilation and operation on iOS. That is, all IL code in the assembly is pre-AOT-compiled to generate a local code image and then load the image directly at run time without using the JIT engine. There are limitations to using the full AOT for technical or implementation reasons, so refer to the Monotouch documentation for a few common examples:
- Generic virtual methods are not supported because, for generic code, mono passes static parsing to determine the type to instantiate and generate code, but static parsing cannot determine which method the runtime actually calls (C + + therefore does not support virtual-template functions).
- P/invoke for generic classes are not supported.
- You cannot assign a value to a non-null type using Property.setinfo in reflection at this time.
- There is a problem with the value type as dictionary key, which actually implements the iequatable<t> type, because dictionary's default constructor uses equalitycomparer<tkey> . The default is the comparator, and for the type that implements the Iequatable<t>, Equalitycomparer<tkey> The default is to instantiate a class that implements the Iequalitycomparer<tkey> by reflection (you can refer to the implementation of equalitycomparer<t>). The solution is to implement a iequalitycomparer<tkey> yourself, and then use Dictionary<tkey, tvalue> (iequalitycomparer<tkey>) The constructor creates an dictionary instance.
- BinaryFormatter Use Serialize. If a container such as list is required to Serialize. Need to add in code System.Environment.SetEnvironmentVariable ("Mono_reflection_serializer", "yes");
- Property cannot use GetValue. Filedinfo can be used normally You can use the property's Getgetmethod (). Invoke to replace. My previous article was useful in initializing a particle object.
- Crateinstence with no more than 9 parameters. hehe. I tried it a little bit.
A list of JIT issues I encountered while using unity to publish the iOS real-time process