wolfpld / tracy

Frame profiler
https://tracy.nereid.pl/
Other
9.89k stars 658 forks source link

Application hangs when connecting to profiler, only when GPU events have been submitted #709

Closed heyallnorahere closed 8 months ago

heyallnorahere commented 9 months ago

I am writing a graphics framework in C#, using these Tracy bindings, linked in the Tracy README. When my application (the neural net project entitled MachineLearning) connects to the profiler, and GPU zones have been submitted, the client application mysteriously freezes.

Steps to reproduce:

The application should freeze in Core/CodePlayground.Graphics/Vulkan/VulkanProfiler.cs on line 90. (Function TracyEmitGpuZoneBeginSerial)

heyallnorahere commented 8 months ago

Reproduced on Windows 11 - though this doesn't hang on the D3D11 example program. Weird.

heyallnorahere commented 8 months ago

Not an issue with the Vulkan context implementation - I just tested the Vulkan backend with a C++ project, and I 1:1 translated the Vulkan context code into my C# codebase. Will continue testing.

heyallnorahere commented 8 months ago

I have verified that replacing the Tracy build used by my C# project via P/Invoke does not fix the issue. I believe this is a problem with the C API. (commit be697f9 on code-playground)

heyallnorahere commented 8 months ago

In fact, debugging native code shows that this is an access violation in tracy::Profiler::SendString calling strlen on an unallocated string. I have verified that I do not pass such a pointer to Tracy (logging all memory allocated by my profiler interface and cross-referencing with pointers provided by the debugger). I do not have insight into how the Tracy client library operates, and so I'm not sure where such a pointer would be passed.

wolfpld commented 8 months ago

What is the call stack leading to SendString?

heyallnorahere commented 8 months ago

On the "Tracy Profiler" thread: image

wolfpld commented 8 months ago

There are certain requirements for the lifetime of data passed to the profiler (detailed in the manual). Your description suggests that the bindings you are using do not meet these requirements. I would suggest creating an issue in that repository, as this does not seem to be a Tracy issue.

heyallnorahere commented 8 months ago

Got it. Thanks.

heyallnorahere commented 8 months ago

Problem solved. This was an issue with me calling ___tracy_emit_gpu_zone_begin_serial instead of ___tracy_emit_gpu_zone_begin_alloc_serial. My bad.