Something different with compile on 2021.3.15f1 +

So my URP game compiles fine on 2021.3.14f1. However, if I upgrade my project to either 2021.3.15 or 2021.3.16 it crashes during build.

Looking at the Editor.log I get the following error before it dies:

Uploading Crash Report
NullReferenceException
at (wrapper managed-to-native)

It then follows on with a “Managed Stacktrace”

=================================================================
Managed Stacktrace:
=================================================================
at <unknown> <0xffffffff>
at UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck <0x001a7>
at DefaultBuildMethods:BuildPlayer <0x013b2>
at UnityEditor.BuildPlayerWindow:CallBuildMethods <0x0098a>
at UnityEditor.BuildPlayerWindow:GUIBuildButtons <0x026c2>
at UnityEditor.BuildPlayerWindow:ShowBuildTargetSettings <0x067a2>
at UnityEditor.BuildPlayerWindow:OnGUI <0x00f12>

Has anyone seen this?

something is wrong with LST releases every new version is buggier

1 Like

I’m having the same issue so I’m staying on 2021.3.14f1 unless this gets fixed. I can build a project made with the URP template on the newer versions but when I’ve added in all of my project assets I get the same crash when building. Crashes on both Windows 11 and macOS M1 so it’s not a platform issue.

I’ve had a look through the patch notes and this change could be the cause:

2021.3.15f1:
Fixes:
Editor: Enabling shader keyword pre-filtering so that build process does not have to enumerate through full shader variant space. This fixes the issue of URP builds even with warm shader cache taking really long time. This fix does not reduce the time spent on actually compiling shaders. (UUM-3711) Unity Issue Tracker - Shader variant build preparation does not scale

This certainly could be the issue. I cleared out my Library folder and on the new version which didnt make a difference either.

How do we fix this problem? Anyone know?
All the new versions have this problem

I guess we should log a case with Unity, or hopefully they see this forum post.

I converted back to 2021.3.14f1 and successfully made a build no other changes needed. Thankfully nothing got corrupted or damaged in the downgrade.

1 Like

Quick update to say this still occurs in the newly released 2021.3.17f1 build.
It also occurs on 2022.2.

I have raised a bug report, but im not sure what causes it so may be too difficult to reproduce

Looks like this, at least in my case, was caused by Unistorm. By removing the render features for that, the crash no longer happened.

I have reached out to the developer of Unistorm for some assistance.

I also use Unistorm.

I’ve also been having issue with builds only rendering light like 10% of the time. So I’m just building and building, hoping for the build that sticks.

Added: After leaving my computer off over night, the build issues I mention where I’m only having a 10% success rate at having a visible build has vanished. Just something to try if anyone sees this and is at odds.

Upgrading to 2021.3.17f1 fixed the issue for me. Thank you to the Unity team for addressing this. I am not using Unistorm though.

1 Like

Managed to fix it by removing UniStorm render features aswell (on version 2021.3.19f1).

The temporary solution is to check all your RenderFeature scripts and mark all fields of UnityEngine.Object derived types with [NonSerialized] attribute, such as:

[NonSerialized]
public Transform shadowCaster;

This is because the GatherFilterData method recursively traverses all the referenced types in the RenderAsset and retrieves their public fields or fields marked with the SerializeField attribute. However, there is a problem with the code logic written by Unity:

        object value = fieldInfo.GetValue(containerObject);
        if (value == null)
        {
            continue;
        }
        Type type = value.GetType();
        if (value is IEnumerable)
        {
            IEnumerable enumerable = value as IEnumerable;
            bool flag2 = settingsNode != null && settingsNode.m_Children.Count > 0;
            foreach (object item in enumerable)

If the data obtained through GetValue in the first line is of the UnityEngine.Object type, Unity casts it as an object, but it is actually a “null” value in the C# object, which is != null. If the value is a Transform type object, the code will run into the foreach loop and retrieve the childCount, causing a NullReferenceException.


Unity, Could you please fix this issue?