Search Issue Tracker
Fixed in 2.0.0
Votes
0
Found in [Package]
1.0.1 preview
Issue ID
1097050
Regression
No
384B GC Alloc in GUIUtility.BeginGUI when using Pixel Perfect Camera
Steps to reproduce:
1. Create new project
2. Import 2D Pixel Perfect package
3. Add Pixel Perfect Camera component to the Main Camera
4. Enter Playmode
5. Open Profiler and look at GC Alloc
Expected result: no extra GC Alloc
Actual result: Extra 384 B in GC only when Pixel Perfect Camera is enabled
Reproducible with: 2018.2.20f1, 2018.3.1f1, 2019.1.0a12
Reproducible with: 1.0.1 preview
-
PauliSavolainen
Jul 20, 2020 06:16
I would suggest to create a separate component such as PixelPerfectDebug attached to the PixelPerfectCamera and move the OnGUI implementation to the debug component. Only when there is something to show the debug component would be enabled. This way OnGUI wouldn't cause GC even in editor/development mode. It is somewhat annoying to see the 384B when profiling in the editor.
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
- The Scene View becomes gray and "NullReferenceException" errors are thrown when attaching the Unity Editor process to RenderDoc
- Memory usage rapidly rises when changing colors in the color wheel
- Physically Based Sky's Horizon and Zenith Tint Color Selection Bars don't have immediate access to color pickers
- EmptyAdditionalLightShadowmapTexture leaks from memory when URP quality level is changed using QualitySettings.SetQualityLevel
- Referenced ScriptableObject field does not get updated and cannot be set to "None" when there are no Objects of that type
Resolution Note (fix version 2.0.0):
The GC allocation is caused by having an OnGUI() callback in the PixelPerfectCamera component. I made OnGUI() only available in the Editor and development builds, as I think it's still useful to have on-screen warning messages, but the GC allocation will be gone in non-development player builds.