Hey all, I'm currently developing a tiny performance panel for our builds. What I want it to do: They need to have render timings and script timings as well as memory. I want to display those stats in a release build. Problem: I've bee using the ProfilerRecorder and it kind of works great. I followed the docs and the video tutorial from unity to get it to work. My main struggle is to get Render Times working. This is how I start all of the recorders. Code (CSharp): void Start() { #if UNITY_EDITOR || DEVELOPMENT_BUILD || SPELLS_ENABLED systemMemoryRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Memory, "System Used Memory"); gcMemoryRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Memory, "GC Reserved Memory"); setpassTimeRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Render, "SetPass Calls Count", 15); renderThread = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "Render Thread", 32); mainthread = ProfilerRecorder.StartNew(ProfilerCategory.Internal, "Main Thread", 32); VertsRecorder = ProfilerRecorder.StartNew(ProfilerCategory.Render, "Vertices Count", 16); StartCoroutine(PostEverySecond()); #else Destroy(gameobject); #endif } void OnDestroy() { systemMemoryRecorder.Dispose(); gcMemoryRecorder.Dispose(); setpassTimeRecorder.Dispose(); renderThread.Dispose(); VertsRecorder.Dispose(); mainthread.Dispose(); } And here is the corde where the values are read and displayed into a text element. Code (CSharp): builder.AppendLine($"Render Thread: {GetRecorderFrameAverage(renderThread) * (1e-6d):F2} ms"); builder.AppendLine($"Main Thread: {GetRecorderFrameAverage(mainthread) * (1e-6d):F2} ms"); builder.AppendLine($"Vertices count: {VertsRecorder.LastValue}"); builder.AppendLine($"System Memory: {systemMemoryRecorder.LastValue / (1024 * 1024)} MB"); As you can see render thread is not printing any values (this is from the editor, but it also doesn't work in the builds) What am I doing wrong? I can't find any clues... I copied the stats name directly from the ProfilerRecorderHandle.GetAvailable() list. I use URP. Regards, Kasimir
I am actually seeing the same issue, and am also using URP. I can't seem to get Render Thread to actually spit out a number reliably. It occasionally works in editor though, but the example code (same i used as well) starts spitting out -3242598439 like numbers as well on that. The specific things i am looking for are actually available in the normal profiler while profiling the device, and the stat is logged as available AND is valid checked before i append the line on screen as well. Bumping for help. PS: Looks like if you are profiling the device in unity, Render Thread suddenly turns up, mostly accurate (90% of the time) the rest just turns 0's again
Where do you get the list of the stat names from please? ... update... found it... https://docs.unity3d.com/Manual/ProfilerMemory.html
Any more info regarding this, tried using the profile recorder for rendering (copy pasted the example) which spits out zeros on URP?
Having the same issue with built-in rendering pipeline.. sometimes I get rendering thread stats but most of the time not. Every time I connect the Unity profiler to the device build it starts spitting out correct values from rendering thread also.
Hi! Sorry for the confusion - the "Render Thread" marker was present among other counters by a mistake and was removed in 2022.2.0a3 to not cause this confusion. Its original purpose was to "name" a thread in Unity Profiler, and as sideeffect of using wrong mechanism it was leaked for ProfilerRecorde's consumption. In most cases the time was equivalent to main thread time and didn't carry any information about any rendering workloads. If you want to get information on render thread and/or GPU frame time metrics please use FrameTimingManager api. We have a blogpost which describes what each of timings mean - https://blog.unity.com/technology/detecting-performance-bottlenecks-with-unity-frame-timing-manager FrameTimingManager data is also available through ProfilerRecorder api
Very interested to know how. Been spending too much time trying to use the FrameTimingManager in v2021 (before learning it's not actually doing anything although existing). And trying to find the stat name strings for ProfileRecorder is a nightmare.