Search Issue Tracker
Fixed in 12.0.0
Fixed in 11.0.0
Found in [Package]
[2D][URP] ShadowCaster2D generates about 1.8 KB of Garbage every frame in the Editor
How to reproduce:
1. Open the attached project named "Case_1304158"
2. Open the SampleScene
3. Open the Profiler Window and Enter Play mode
4. In the CPU section, search for PlayerLoop -> Update.ScriptRunBehaviorUpdate -> BehaviorUpdate -> ShadowCaster2D.Update()
5. Observe the GC Alloc statistics
Expected results: ShadowCaster2D does not generate garbage every frame
Actual results: Each ShadowCaster2D object in the Scene generates roughly 1.8 KB of garbage every frame
Reproducible with: 7.5.2(2019.4.19f1), 10.2.2(2020.2.3f1), 11.0.0(2021.1.0b3), 12.0.0(2020.2.0a3)
Could not test with: 2018.4(URP was in early preview stage)
1. Does not reproduce in the Build. Attaching a profiler to the Build shows 0 B of garbage generated by ShadowCaster2D.Update()
Jun 29, 2021 14:48
Will this fix be backported to 2020 LTS release?
Feb 16, 2021 16:12
In the update function of ShadowCaster2D.cs, the first line is:
Renderer renderer = GetComponent<Renderer>();
Surely that's a huge problem?
Feb 05, 2021 16:50
Got this problem too for over a year i'm trying to find a solution. All my shadowcaster2d are creating at least 1.3kb of GC each. I've seen it in editor mostly but seeing the freeze i get when the shadowcaster get enabled in webgl build make me think it happen there too.
Also by disabling/enabling the component in runtime i cumulativly get more batching, to a point the game will crash.
It need a big look up in general.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- NullReferenceException error thrown when changing Scenes in Play Mode
- Crash on "'anonymous namespace'::ConvertFBXShapes" when importing an FBX file
- Crash on Transform::RemoveFromParent when Object.DestroyImmediate() is called on Transform
- [Linux] Player consumes more CPU resources when it is running in the background
- Save process is triggered every time when prefab property values are changed by dragging
Resolution Note (fix version 12.0.0):
A fix for this issue is available on Universal RP package 12.0.0 and above with Unity 2021.2.0a9
Resolution Note (fix version 11.0.0):
A fix for this issue is available on Universal RP package 11.0.0 and above