Hi there!
I regularly profile my game and noticed something I don’t remember seeing before: calls to Graphics.ExecuteCommandBuffer_Injected() showing up under the Update hierarchy. Initially I assumed this came from a script higher up the stack, but disabling that script just makes the injection point reappear elsewhere.
My assumption is that this is how Unity is intended to work. I was wondering if someone from Unity could explain what the underlying mechanism is for this injection of expensive logic.
From a profiler standpoint, I’m also trying to understand causation: does the frame time on these calls primarily scale with the number of active renderers, bounding volumes, particle/VFX systems, or something else?
It’s a bit surprising to see this show up in a seemingly random place within the call stack.
Hi @MartinTilo
Is this an expected behavior? Is it a function of the profiler or Unity?
Is this with Deep Profiling?
And could it be that something in the code there triggers a GraphicsFence?
Do you have examples of it popping up elsewhere?
@MartinTilo
Thanks for responding to this question.
Is this with Deep Profiling?
If I enable deep profiling it disappears!
And could it be that something in the code there triggers a [GraphicsFence]
I’m not explicitly using a fence. I did a file contents search of my project and all associated packages. I didn’t come across any usage of “Graphics.CreateGraphicsFence”.
Do you have examples of it popping up elsewhere?
I see it within profiling via the editor and builds with debug enabled. *grabbing a screenshot of it appearing elsewhere.
As it disappears when deep profiling, that kinda sounds like a bug to me. If you have a repro project you could share, please report it via the Editor menu Help > Report a Bug 
(Granted, deep profiling could just shift the timing so that the sync fence isn’t hit there)
@MartinTilo
Here is an example of the duplication, i.e. where it pops up elsewhere. This is in the context of a single profiler frame.
- I realized it shows up too many times to itemize. Here is a search result of the single frame:
Here is a link to the profiling data: https://stellarconquest.blob.core.windows.net/tmp/unity/Profiling.data (197 MB)
It is clearly consuming CPU time. I don’t know enough about this behavior to understand whether I should even be angry at the performance overhead.
The behavior is manifesting in a game that is close to public release and, for this reason, it is not a small sample project.
I can try to isolate and recreate the behavior. Could I get some feedback on what these methods are doing? This will help me recreate the behavior, assuming it is something to be avoided.