- Home /
IOS IL2CPP runtime error NullReferenceException
Hi all, currently I'm working on update for my old game. Previously I compiled it with Unity 5.0.x with Mono2x and all was good. Currently I'm trying to compile it with Unity 5.3.4f1 with IL2CPP (iOS Universal Architecture) and at run-time I'm getting 2 errors:
NullReferenceException: A null value was found where an object instance was required.
at PauseMenu.endGameButtonClick () [0x00000] in <filename unknown>:0
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: A null value was found where an object instance
was required.
at PlayerController..ctor () [0x00000] in <filename unknown>:0
(Filename: currently not available on il2cpp Line: -1)
NullReferenceException: A null value was found where an object instance was required.
at PlayerController..ctor () [0x00000] in <filename unknown>:0
(Filename: currently not available on il2cpp Line: -1)
PauseMenu.endGameButtonClick references to button's click callback, and I don't call it at all (If I delete this function I got another similar error, references to another button callback from this PauseMenu C# script)
Second error logs at every frame update (I have tried to delete Update and FixedUpdate from my PlayerController, but this was not help)
Meanwhile I made Android build with Mono2x and it working good.
I'm not sure about the exact cause of the error, but I can point you to a few resources to help track it down:
IL2CPP INTERNALS – DEBUGGING TIPS FOR GENERATED CODE (blog post)
IL2CPP: Profiling and Debugging (video)
Both of these resources discuss specifically how to debug the generated C++ code in Xcode to track down the cause of an exception.
Initially, I would suspect that something is wrong with the code stripping in this case, as that is a key difference between the $$anonymous$$ono and IL2CPP build toolchains. The IL2CPP toolchains more aggressively strips managed code in assemblies in your project. So whatever is causing the null value may have been stripped away.
Thanks for links, yes, I also thought about code stripping and disable it, but the error was much more simpler, just null transform I use at specific platform only
Answer by litebox · Mar 30, 2016 at 01:04 PM
After disabling / enabling parts of scene and comment / uncomment parts of PauseMenu class I finally found a problem:
if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
copyrightTransform.gameObject.SetActive(false);
All is simple, this object was null. Unfortunately IL2CPP doesn't provide exact place of problem, instead of this it references to random parts of class and this is confusing even more.
I'm not following sorry. Is the managed call stack provided by IL2CPP incorrect? Did the NullReferenceException occur in a different method from Pause$$anonymous$$enu.endGameButtonClick?
Yes, NullReferenceException occurs at Pause$$anonymous$$enu::Start() method
Can you provide this project with a bug report? The call stack in the exception should be correct. I would like to investigate why it is wrong.
Your answer
Follow this Question
Related Questions
.net socket disconnection exception 0 Answers
Unity Build IOS XCODE build error ReentrantLock 0 Answers
IOS build size using IL2CPP 1 Answer
Unity www class crashes on iOS 64 bit 2 Answers
Build error with IL2CPP 3 Answers