PostProcessLayer.ResetHistory causing a null reference exception after upgrading cinemachine from 2.9.7 to 3.1.2

Details:

After upgrading from 2.9.7 to 3.1.2, this error started popping out.

  1. If a PostProcessLayer attached to the camera is disabled, it will cause the null reference to trigger. Having the PostProcessLayer enabled will not trigger the null reference.

I tried removing and adding the post process layer, but the issue is not resolved.

HOTFIX: Calling PostProcessLayer.InitBundles() in OnValidate method seems to fix the issue.

Complete log:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.Rendering.PostProcessing.PostProcessLayer.ResetHistory () (at ./Library/PackageCache/com.unity.postprocessing@3.4.0/PostProcessing/Runtime/PostProcessLayer.cs:846)
Unity.Cinemachine.CinemachinePostProcessing.OnCameraCut (Unity.Cinemachine.ICinemachineCamera+ActivationEventParams evt) (at ./Library/PackageCache/com.unity.cinemachine@3.1.2/Runtime/PostProcessing/CinemachinePostProcessing.cs:218)
UnityEngine.Events.InvokableCall`1[T1].Invoke (T1 args0) (at <011ccacb58784a80ac4b48b4c50ee0b7>:0)
UnityEngine.Events.UnityEvent`1[T0].Invoke (T0 arg0) (at <011ccacb58784a80ac4b48b4c50ee0b7>:0)
Unity.Cinemachine.BlendManager.ProcessActiveCamera (Unity.Cinemachine.ICinemachineMixer mixer, UnityEngine.Vector3 up, System.Single deltaTime) (at ./Library/PackageCache/com.unity.cinemachine@3.1.2/Runtime/Core/BlendManager.cs:173)
Unity.Cinemachine.CinemachineBrain.ProcessActiveCamera (System.Single deltaTime) (at ./Library/PackageCache/com.unity.cinemachine@3.1.2/Runtime/Behaviours/CinemachineBrain.cs:640)
Unity.Cinemachine.CinemachineBrain.ManualUpdate () (at ./Library/PackageCache/com.unity.cinemachine@3.1.2/Runtime/Behaviours/CinemachineBrain.cs:547)
Unity.Cinemachine.CinemachineBrain.LateUpdate () (at ./Library/PackageCache/com.unity.cinemachine@3.1.2/Runtime/Behaviours/CinemachineBrain.cs:250)