Profiler doesn`t see the thread group I have added to watch

I have an assembly without Unity Engine References. I want to monitor threads from that assembly definition in profiler window so, I have the following code in my thread job:

 public void threadJob()
     // ... thread code

and in my other assembly (with Unity Engine Reference) I have the code:

var request = someObject;
var samplerPollState = CustomSampler.Create("GET Request");
state.beginProfileAction = () =>
    Profiler.BeginThreadProfiling("Network Thread", "GET request " + request.GetHashCode());
state.endProfileAction = () =>

Why can't unity monitor the code?

After that I put teh begin and end profile action in the assembly that had Unity References Excluded and I have unchecked the exclusion of Unity References. The thread was present in profiler. Is it some Unity limitation?

What does that mean? Do you actually start your own thread? Or do you talk about using Unity’s job system? Note that

Calling this method on an internal Unity thread (such as main thread, render thread or job system threads) has no effect
[/quote] - Profiler.BeginThreadProfiling.

Actually, I start my own Thread. I have several threads that I start by my own and they have lifetime equals to the main thread.

I had never used the BeginThreadProfiling method before. However I quickly created a background thread, essentially added your code with some dummy Thread.Sleeps in it, removed the request hashcode from the thread name and have the thread run in the background. The thread shows up for me in the thread selection:

When I select the thread, I can find "occational" logs since I sleep for 50ms and have "load" for 10ms in between begin and end. Note that when the thread finishes it will disappear from the selection.

So you should not use a variable name for the thread. The thread name is used to identify it in the thread selection. If you're changing the thread name at every begin, you will have issues picking that thread in the first place. Is your thread actually running in the background? Or do you spawn a new thread for every network request?

The thread list is quite long:
So it might be difficult to actually find your thread. What should help is to switch the Profiler into Timeline mode. That way your thread actually show up under your thread group name:

1 Like