Errors with Profiler.EndSample

Hi there. I just updated from 2021.1.23f1 to 2021.2.0b15 and found the deferred feature. I was happy, that finally the lighting was working for me (using Hybrid Renderer V2).

But also every frame i get some errors, and i can’t figure out what it is. It looks like a timing issue to me, it cannot find a endsample than its missing it…

Any ideas? (when starting the scene)

Update: it seems just happening when the Profiler-Window is open. Closing it will not cause the errors… But still this is not good :slight_smile:

Hi there, it’s this bug, which we already have in our bug tracker and are looking at solutions for.

Ah, perfect. Thanks for the fast response :slight_smile:
Anyway i got a bad exception due to burst compile error, with no explains when trying to compile. So I downgraded already :frowning:

still happen, 2021.3.5f1

2 Likes

still happening in 2021.3.15f1

We are experiencing this on Unity 2021.2.5f1 and thus cannot use Profiler AT ALL. This is very critical!!!

Hey @StenCG & @nopogo ,

The bugfix landed before those versions so what you are seeing must be a separate bug with the same symptoms. For us to be able to fix that, we’ll need a new bugreport, possibly even 2, one from each of you, in case those are separate issues. We do not have any details that would point us at what else is still broken here.

@Haapavuo as mentioned in a comment on the issue tracker page, the fix landed on 2021.2.12f1, so your version does not yet contain the fix. If you upgrade and still experience the same issue, a new bug report would also be needed from you for us to be able to fix the issue.

Also, thank you for bringing it up that there is still more here that needs fixing :slight_smile:

1 Like

still happening in Unity 2023.2.1f1 (and be able to remove this bug after closing profile window)

as I upgraded from 2023.1.16f1

And it looks like thie legacy bug will still exist in Unity 6

To be clear, every instance where this error log resurfaces after being fixed is most definitely a new bug with a new source. It’s not like we don’t fix the same issue properly over and over, it’s a bug in the usage of the ProfilerMarker API that needs to be fixed whereever that API was used in the wrong way. That could be C# Editor or Engine code, or a package, or User code.

So if you checked that this is not happening due to something inyour code, please always file a new bug report for it, so that the respective team can fix the faulty usage. :slight_smile:

Something that we do need to fix systematically is adding support for ProfilerMarker API to be able to span a scope over a call to async await. That would currently trigger this log.

Hi , problem still on 2019.4 LTS version. Is there any possible be fixed ?

That LTS version has dropped out of the support Window in 2022, so no, there won’t be any fixes for it.

i use 2023.2.1f1 same problem

Missing Profiler.EndSample (Every BeginSample call must have a subsequent EndSample call within the same frame): Gfx.UploadTexture
Previous 5 samples:
Gfx.UploadTexture
RenderLoop
Semaphore.WaitForSignal
Gfx.WaitForGfxCommandsFromMainThread
AsyncUploadManager.ScheduleAsyncCommands
In the scope:
Gfx.UploadTexture
RenderLoop

Non-matching Profiler.EndSample (Every EndSample call must have a preceding BeginSample call within the same frame): Gfx.UploadTexture
Previous 5 samples:
RenderLoop
Semaphore.WaitForSignal
Gfx.WaitForGfxCommandsFromMainThread
Gfx.UploadTexture
RenderLoop
In the scope:
RenderLoop

Missing Profiler.EndSample (Every BeginSample call must have a subsequent EndSample call within the same frame): Gfx.UploadTexture
Previous 5 samples:
Gfx.UploadTexture
RenderLoop
Semaphore.WaitForSignal
Gfx.WaitForGfxCommandsFromMainThread
Gfx.UploadTexture
In the scope:
Gfx.UploadTexture
RenderLoop

1 Like

That’s a different profiler-sample-stack, hence definitely a different bug. Can you please report it via the Editor menu Help > Report A Bug?

I had a very similar error (beginning with Non-matching Profiler.EndSample (Every EndSample call must have a preceding BeginSample call within the same frame)) while having the profiler open.
I was doing

context.Submit();```
inside my
```using (new ProfilingScope(cmd, profilingSampler))```
in
```Execute()```
and removing
```context.Submit();```
got rid of the error and did not impact anything visually.
2 Likes

Still happening, very easily reproducable with Unity’s own examples

Which ones and which specific version?

The same problem. Unity 2021.3.36f1


Ehm, you are actively closing the sample in the wrong scope? That error is correct.

I think you’re expecting this to allow some kind measurements that is async to the profiling scopes it happens within (and Update is auto instrumented but even if it was started in Update and ended in a non Auto-Instrumented function called from within Update, it would still mismatch on turning on Deep Profiling) like a stopwatch, but it isn’t. You need to close your profiling scopes in the same function where you started them, as you’re just adding your sample to a stack of samples.