- Home /
link.xml for a monobehaviour?
Hi,
I have basically a monobehaviour and I use reflection to access one of it's getter, and it fails to work on IOS when stripping.. so I would like a confirmation that this link.xml is properly formatted and the problem would then be elsewhere.
What is the correct link.xml content for a monobehaviour then?
The error I get is:
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method 'System.Reflection.MonoProperty:GetterAdapterFrame<PlayMakerThirdPersonControllerProxy, int> (System.Reflection.MonoProperty/Getter`2<PlayMakerThirdPersonControllerProxy, int>,object)' while running with --aot-only.
at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
at HutongGames.PlayMaker.ReflectionUtils.GetMemberValue (System.Reflection.MemberInfo member, System.Object target) [0x00000] in <filename unknown>:0
at HutongGames.PlayMaker.ReflectionUtils.GetMemberValue (System.Reflection.MemberInfo[] memberInfo, System.Object target) [0x00000] in <filename unknown>:0
at HutongGames.PlayMaker.FsmProperty.GetValue () [0x00000] in <filename unknown>:0
thanks,
Jean
What stripping level are you using? The highest level breaks reflection I believe.
What do you mean by link.xml?
What's the use-case for using reflection? Is it a private getter you're accessing? Is it on the $$anonymous$$onoBevahior class or you subclass or another super?
Hi Bovine. I am using a normal behavior public variable, no fancyness here. I am using Play$$anonymous$$aker to access that behavior public property, that's why I need reflection. link.xml is suppose to allow for reflection... http://docs.unity3d.com/Documentation/$$anonymous$$anual/iphone-playerSizeOptimization.html
Ahh, I didn't know you could do that. A daft question but are you white-listing the right class? Do you need to add all super classes, what about subclasses? I don't know how it works, so perhaps you need the complete list?
Either way you could experiment by simplifying the case - in a new temp project link Play$$anonymous$$aker to a getter on a class you have created and see if that simple case works with stripping and your whitelist.
If it does, subclass your class and see if it still works without changing the white list.
The type being inspected is key I suspect, so if it does work, then have Play$$anonymous$$aker link with your subclass and see if that works without changing the whitelist?
maybe, but the question is really about knowing what exactly is the content of link.xml when I want to white list a monobehaviour. Currently I can't find anything on the web that clearly shows a working example using a monobehaviour...
Answer by Graham-Dunnett · Feb 11, 2013 at 11:04 AM
link.xml
allows you to tell the stripper that certain .NET features should not be removed. It's not really related to reflection in any way, just use of reflection is something the stripper doesn't know about. It should not be needed if you are just using regular MonoBehaviour
things.
Also, bear in mind that reflection usually requires code to be generated and compiled at runtime. Runtime code-generation is not supported on iOS devices.
@Graham Dunnet while you cannot have runtime generated code on iOS devices you can still use generics - I believe mono pre-compiles variations of code to get around this, but I don't pretend to understand the problem, so much as the solution, here's the problem or discussion about trampolines at least:
http://www.mono-project.com/$$anonymous$$ono:Runtime:Documentation:Trampolines
Here's the solution (see iOS section):
http://docs.unity3d.com/Documentation/$$anonymous$$anual/TroubleShooting.html
We use the following AOT settings:
lines=8192,ntrampolines=8192-trampolines=8192,ntrampolines=8192
The upshot for us is that we strip to byte code level and increase the size of our trampoline pool. Naturally there is some memory cost associated with this, but thus far it hasn't proved a problem - we are already WAY over 20$$anonymous$$B anyway :D