ZoneScoped randomly not closing with TRACY_ON_DEMAND
Currently using tracy with multi dll setup which was working fine, but when enabling TRACY_ON_DEMAND the scopes randomly don't close which leads to constant stacking. I also tried TRACY_IMPORTS which doc says is required for dlls on windows but it doesn't seem to matter.
I had just run into this issue @toodemhard, What fixed it was also defining TRACY_ON_DEMAND within my .dll which contained the TracyProfiler aswell as my application i was using that .dll within.
Related issue #610
It should have been defined for both but maybe my build went stale again so thanks for the tip. Will try next time I need to profile again.
I'm having the same issue. I'm running Tracy in a DLL that gets reloaded (that is, my program loads multiple live copies and only calls into the most recent one), and running Tracy normally, it works totally fine, which surprised and delighted me! But with TRACY_ON_DEMAND scopes don't close. I tried manually doing it with ZoneNamed but it had the same result.
I only wanted to do "on demand" so that I would have a means to turn profiling on and off while the game is running. 🤔
Most of Tracy's client markup code is header-only, and requires you to have consistent flags across all translation units to exhibit correct behaviour. Mixing flags is always bad, except for TRACY_ENABLE. You could use that to enable/disable tracing per source file or shared library. Other flags must be consistent.
Note that it is documented here for multi-dll projects https://github.com/wolfpld/tracy/blob/be7b116a658c0576959609d5bf33f5c392b9753f/manual/tracy.tex#L572-L575
But we might want to warn a bit more aggressively in the setup part, as it does mention the issue for TRACY_ENABLE but not other defines. The issue can happen across different translation units from the same library if they setup defines incorrectly too.