Build fails with error: Player export failed. Reason: 3 errors

Description of issue: The build is failing with a non-descriptive error. There is also the error " Assertion failed on expression: ‘ms_Instance != NULL’"

Unity version: 5.6.0f3

Source control: git

Local build platform: Windows

Build target: Android

Build log (relevant chunk):

98666: [Unity] *** Completed 'Build.Player.AndroidPlayer' in 174 seconds (174193 ms)
98667: [Unity] Player export failed. Reason: 3 errors
98668: [Unity] UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
98669: [Unity] UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
98670: [Unity] UnityEngine.Logger:Log(LogType, Object)
98671: [Unity] UnityEngine.Debug:Log(Object)
98672: [Unity] UnityEditor.CloudBuild.BuildLogger:Log(String, Object[])
98673: [Unity] UnityEditor.CloudBuild.Builder:Build()
98674: [Unity] Refresh: detecting if any assets need to be imported or removed ... Refresh: elapses 0.162417 seconds (Nothing changed)
98675: [Unity] Refresh: detecting if any assets need to be imported or removed ... Refresh: elapses 0.143060 seconds (Nothing changed)
98676: [Unity] Cleanup mono
98677: [Unity] Checking for leaked weakptr:
98678: [Unity]   Found no leaked weakptrs.
98679: [Unity] Assertion failed on expression: 'ms_Instance != NULL'
98680: [Unity] ##unity-automation:{"messageType":"MemoryLeaks","allocatedMemory":16627346,"memoryLabels":[{"Default":96},{"Permanent":16128},{"NewDelete":4194320},{"Thread":616},{"Manager":1976},{"GfxDevice":21664},{"GfxThread":2688},{"Physics":8},{"Serialization":12704},{"JobScheduler":144},{"GarbageCollector":1048576},{"Renderer":224},{"Terrain":224},{"STL":131584},{"String":122025},{"DynamicArray":3112},{"Utility":-1048576},{"PoolAlloc":-224},{"ScriptManager":3280},{"Sprites":12096336},{"VR":11404},{"EditorUtility":544},{"AssetImporter":712},{"RestService":64},{"License":965},{"UnityConnect":6024},{"Collab":728}]}
98681:  ! Unity player export failed!
98682: ! build of 'android-dev-josh' failed. compile failed
98683: Publishing build 45 of east-side-games/trailer-park-boys-greasy-money for target 'android-dev-josh'...
98684: publishing finished successfully.
98685: Storing CACHE_PATH to cache key library_5_6_0f3
98686: done.
98687: Build step 'Execute shell' marked build as failure
98688: postbuildstatus finished successfully.
98689: Finished: FAILURE

Does it build locally from a fresh checkout? Yes

esg-joshmorhart did you manage to fix the issue?

We’re hitting this as well, on Unity 5.6.2p3:

Assertion failed on expression: 'ms_Instance != NULL'
(Filename: C:\buildslave\unity\build\Runtime/Network/PlayerCommunicator/ManagedProxy/GeneralConnectionManaged.cpp Line: 118)

##unity-automation:{"messageType":"MemoryLeaks","allocatedMemory":1375755,"memoryLabels":[{"Default":64},{"Permanent":20240},{"NewDelete":257748},{"Thread":608},{"Manager":3016},{"VertexData":288},{"GfxDevice":27404},{"GfxThread":2688},{"Physics":8},{"Serialization":12704},{"JobScheduler":136},{"GarbageCollector":1048576},{"BaseObject":512},{"Renderer":224},{"Skinning":104},{"Terrain":224},{"STL":131584},{"String":185450},{"DynamicArray":3324},{"Utility":-1048576},{"PoolAlloc":-224},{"ScriptManager":3280},{"Sprites":705416},{"VR":12908},{"EditorGui":12},{"EditorUtility":544},{"AssetImporter":32},{"RestService":72},{"License":653},{"UnityConnect":6032},{"Collab":704}]}

Any ideas?

Any update on this issue?

For our project, we narrowed the issue down to a Volumetric Lighting addon we grabbed from here: GitHub - Unity-Technologies/VolumetricLighting: Lighting effects implemented for the Adam demo: volumetric fog, area lights and tube lights

When using Unity’s batch mode to headlessly build, it causes the error I pasted above. I didn’t get to the point where I narrowed down the precise code that was causing the issue, but it seems TubeLight.cs and AreaLight.cs when compiled in would cause issues. I’ve attached a min project to hit the issue for the Unity devs (and am linking my bug report on the Volumetric Lighting project here: Project Fails to Headlessly Build in Unity 5.6+ With Unity Assert · Issue #14 · Unity-Technologies/VolumetricLighting · GitHub)

Repro steps:

  • Make a new project in Unity 5.6+ (tested in 5.6.1p4 and 5.6.2p3)
  • Drop the attached assets folder in
  • Close Unity
  • Run the batch script “sparkbuild_test.bat” contained in the folder on Windows

Expected: a successful build
Actual: Build sort of succeeds (files are correctly output), but Unity returns an error in post-processing. Logs are as my post above. Note the build succeeds when done from within the Editor.

It looks like a Unity bug to me, but am unsure. Figured it’d be best to post both here and in the project I found the bug in.

3151660–239556–VolumetricLightingBuildFail.zip (550 KB)

Hopefully the Unity staff can see it and take a look into it for you also, we are having an issue with our code accessing a dll file that apparently isn’t meant to be accessible from a C# unity build… but it still builds on our local systems - but not on cloud build.

Hi esg-joshmorhart,
Did you manage to fix the issue? getting the same with batchmode building in Unity 5.6.2p4