Crash on iOS 11 startup - Unity 2017.2.0f3, IL2CPP, .NET 4.6 runtime

Greetings. I upgraded to Unity 2017.2.0f3 on our project this morning. Everything seemed to go well, except for our iOS builds. I am getting strange null ref errors, and crash logs that were not present in 2017.1.

First, I was getting crash logs related to Metal’s rendering thread. I disabled Metal, and the application starts, but with this error:

NotSupportedException: /Users/builduser/buildslave/unity/build/External/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System/Environment.cpp(166) : Unsupported internal call for IL2CPP:Environment::get_HasShutdownStarted - "This icall is not supported by il2cpp

This is followed up by several null reference errors pointing to auto-initialized member variables within my application. Not sure what’s up. Has anyone else seen this? I am going to have to roll back to the prior Unity version for now, I suppose.

We have recently implemented get_HasShutdownStarted so expect the NotSupportedException to go away. Do you have more details on the NullReferenceExceptions?

Hi @joncham
Cool. Glad to hear it. Seems like this was an issue in 2017.1, and was resolved. Why’d it show back up in 2017.2?

As for the null ref exceptions… I don’t know what to say, really.

Seems like anything that tries to reference a (reference type) member variable that’s set to auto-initialize when the class is instantiated is curiously null. I have several of these variables that are initialized upon instantiation that are used to pre-cache configuration, for setting up collision handlers, etc.

I have it all being logged to cloud build, if you would like to see more. Again, this has never occurred in the previous version of Unity. I just started seeing this in 2017.2.

When I had Metal enabled, the above was still occurring, though there was a Metal specific crash logged, as well. I can confirm that this is occurring on all of my test devices running iOS 11:

Native Crash - __pthread_kill (Unknown File)

Thread 8 (crashed)
0   libsystem_kernel.dylib              __pthread_kill
1   libsystem_c.dylib                   abort
2   libsystem_c.dylib                   __assert_rtn
3   Metal                               MTLReportFailure
4   AGXMetalA11                         <system symbols missing>
5   cublitz                             MetalContext::CreateNewEncoder(MTLRenderPassDescriptor*, bool)
6   cublitz                             SetupMetalFBO(GfxDeviceMetal&, GfxClearFlags, ColorRGBAf const&, float, unsigned int)
7   cublitz                             metal::PrepareRenderTargetIfNeeded(GfxDeviceMetal&)
8   cublitz                             GfxDeviceMetal::SetShadersThreadable(GpuProgram**, GpuProgramParameters const**, unsigned char const* const*)
9   cublitz                             GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&)
10  cublitz                             GfxDeviceWorkerAutoreleasePoolProxy
11  cublitz                             GfxDeviceWorker::RunExt(ThreadedStreamBuffer&)
12  cublitz                             GfxDeviceWorker::Run()
13  cublitz                             GfxDeviceWorker::RunGfxDeviceWorker(void*)
14  cublitz                             Thread::RunThreadWrapper(void*)
15  libsystem_pthread.dylib             _pthread_body
16  libsystem_pthread.dylib             _pthread_body
17  libsystem_pthread.dylib             thread_start

False alarm. It appears to be caused by the NestedPrefabs asset. Disabling it stopped the crashing and strange behavior. Thanks for your time.