I am using Unity version 4.6.9. I am getting crash with “ArgumentNullException: Argument cannot be null”. Everything works fine when building with Mono and for Android. Is this related to prime31? Does anyone came across this issue?
Below is the null exception i am getting in Xcode (version 6.4):
(Filename: /Users/builduser/buildslave/unity/build/artifacts/iPhonePlayer-armv7-il2cppGenerated/UnityEngineDebug.cpp Line: 56)
ArgumentNullException: Argument cannot be null.
Parameter name: collection
at System.Collections.Generic.Dictionary`2[System.String,Prime31.Reflection.CacheResolver+MemberMap]..ctor (System.Runtime.Serialization.SerializationInfo info, StreamingContext context) [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[UnityEngine.Camera].CheckCollection (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
at System.Collections.Generic.List`1[UnityEngine.Camera].AddRange (IEnumerable`1 collection) [0x00000] in <filename unknown>:0
at OutpostProgressModel.InitTowerPlacements () [0x00000] in <filename unknown>:0
at UserInfo.GetOutpostProgress (OutpostType outpostType) [0x00000] in <filename unknown>:0
at UserInfo.GetOutpostProgress (RegionType regionType) [0x00000] in <filename unknown>:0
at RegionMap.Init (.UISceneState state) [0x00000] in <filename unknown>:0
at UISceneState+<Load>c__IteratorE5.MoveNext () [0x00000] in <filename unknown>:0
at RegionMapSceneState+<Load>c__Iterator156.MoveNext () [0x00000] in <filename unknown>:0
at CoreTask.MoveNext () [0x00000] in <filename unknown>:0
[B](Filename: currently not available on il2cpp Line: 4294967295)[/B]
Usually when we see a managed NullReferenceException exception on IL2CPP and not on Mono, it means that something in the IL2CPP stripping process removed some code a bit too aggressively. You can usually verify this by building using the Mono scripting backend with byte code stripping enabled. You may see the same issue.
In order to determine what was incorrectly stripped, you may need to debug the generated C++ code when the exception occurs. You can set an exception breakpoint in Xcode, then look up the native call stack to see what is missing. See this blog post for some details:
Once you determine what is missing, you can use a link.xml file to preserve the things that are getting stripped. You can find more details here:
Note that I’m only guessing about the cause of the problem though. If you debug this and find that my guess here does not make sense, we may need to have a look at the project in a bug report.
@JoshPeterson
Hey as you said when using Mono scripting backend with byte code stripping enable, this is issue is coming; this definitely means what you are guessing is right. Some thing is getting stripped when i am compiling with IL2CPP.
I was trying to find what is getting incorrectly stripped in il2cpp but I am unable to understand the generated C++ code, its not readable code for me, Below is the link.xml’s we have int he project and the stack trace output on crash:
What should we do? or do i need to create bug report for this?
we have two link.xml files in the project for preserving.
I am facing difficulty in determining which classes are getting stripped in error even though the game requires them; I have tried comparing Xcode projects for stripped byte code of 32 bit and disabled stripping cde of 32 bit.
Thanks for the details. I’m now wondering if this is related to stripping of some native engine code instead of managed code. For stripping of native engine code, the link.xml will not have an impact, as it only deals with managed code. Can you attempt to set the “Stripping Level” option in the Player Settings to a value of “Disabled” (if it is not already). That will prevent the native engine code from being stripped, and may correct this issue.
If that still does not work, then it is probably a good idea to submit a bug report, and we can have a look.
@JoshPeterson Yes, I will submit a bug report and inform you. I have to take permission from management. @MrEsquire Yes. I have checked we are using latest Prime 31 plugins also we were able to create other IL2CPP projects successfully using same Prim31 updates.
@JoshPeterson update: we have just found that this project (32 bit) is working fine only with Unity 4.6.2f1. Game is released on appstore using Unity 4.6.2f1. From 4.6.3 onwards we are getting this issue for 32 bit also.
64 bit is not working with latest IL2CPP unity patches we have tried 4.6.9p1,p2 and p3. Are you guys looking into this issue?