Search Issue Tracker
Fixed
Fixed in 6000.0.14f1, 7000.0.0a1
Votes
1
Found in
2023.2.19f1
6000.0.0b15
6000.1.0a7
6000.2.0a1
7000.0.0a1
Issue ID
UUM-69806
Regression
No
HDRP LightLateUpdate allocates every frame for each light in the scene when in Play Mode
Reproduction steps:
1. Open the “ReproProject“ project
2. Open the “Assets/OutdoorsScene“ scene
3. Open the Profiler window (Window > Analysis > Profiler)
4. Enter Play Mode
5. Select any frame in the Frame chart in the Profiler window
6. Expand the “PlayerLoop“ in the Hierarchy of the Profiler window
7. Observe the “LightLateUpdate“ allocations in the Hierarchy of the Profiler window
Expected result: No allocations in the LightLateUpdate
Actual result: 25 allocations in the LightLateUpdate
Reproducible with: 2023.2.19f1, 6000.0.0b15
Couldn’t test with: 2021.3.37f1, 2022.3.25f1
Reproducible on: Windows 11 Pro (22H2)
Not reproducible on: No other environment tested
Comments (1)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- UnityLinker causes crash when outputting snapshot data for very large projects
- Camera Preview does not detect multiple cameras with same GameObject name
- Crash on TypeTreeIterator::Children() when renaming a corrupted asset while Asset Serialization is set to Mixed
- Cameras (Camera.targetDisplay) render only to Display 0 in the Player when Multi-Display setup is used and DX12 API is set
- [Vulkan] _CameraOpaqueTexture produces a feedback effect on Android Adreno devices when using Vulkan
Daniel-Dorotik
Jun 05, 2024 17:37
Hello,
I have encountered the same issue with memory allocations in the LightLateUpdate method and can confirm that it is reproducible in Unity 2023.2.20f1 with HDRP package version 16.0.6, as well as Unity 6 Preview (6000.0.4f1) with HDRP package version 17.0.3.
Upon further investigation, I found that the source of allocations is within the HDAdditionalLightData.TickLateUpdate method. Specifically, the line int idx = directionalLights.FindIndex((x) => ReferenceEquals(x, lightData)); causes allocations due to the lambda expression capturing the lightData variable.
To resolve this issue, I replaced the lambda expression with an explicit for loop, as shown below:
else if (lightData.legacyLight.type != LightType.Directional)
{
for (int dirLightIndex = 0; dirLightIndex < directionalLights.Count; dirLightIndex++)
{
if (ReferenceEquals(directionalLights[dirLightIndex], lightData))
{
directionalLights.RemoveAt(dirLightIndex);
break;
}
}
}
This change eliminates the need for a closure and the associated delegate creation, preventing memory allocations in this part of the code. In the Profiler, these allocations show up under LightLateUpdate, and activating the Call Stacks functionality reveals that they originate from HDAdditionalLightData.TickLateUpdate.