tracy icon indicating copy to clipboard operation
tracy copied to clipboard

TRACY_ON_DEMAND causes "Zone is ended twice" instrumentation failure

Open davidvodnik opened this issue 1 year ago • 2 comments

Description

I keep getting Zone is ended twice failures when compiled with TRACY_ON_DEMAND. Without this flag it works fine.

I debugged tracy profiler and in the failing cases I am getting QueueType::ZoneEnd before any QueueType::ZoneBegin.

Workaround

I can patch void Worker::ProcessZoneEnd( const QueueZoneEnd& ev ) function to ignore the mismatched QueueType::ZoneEnd, and the issue goes away.

    if( td->zoneIdStack.empty() )
    {
        //ZoneDoubleEndFailure( td->id, td->timeline.empty() ? nullptr : td->timeline.back() );
        return;
    }

I also needed to ignore timeEnd smaller than zone->Start().

    //assert( timeEnd >= zone->Start() );
    if (timeEnd < zone->Start()) {
        return;
    }

Questions

  • Where are mismatched QueueType::ZoneBegin and QueueType::ZoneEnd supposed to be handled?
  • Is the client supposed to send a coherent stream?
  • Or is the server supposed to handle that case?

Additional Information

  • Tracy version: 0.11.0, also 0.10.0
  • Platform: Windows, OSX

davidvodnik avatar Aug 21 '24 07:08 davidvodnik

I have had this exact issue for a while now. Would be nice if it got fixed.

Ggjorven avatar Aug 22 '24 20:08 Ggjorven

I encountered this issue during very early profiler startup in my process. A workaround I found was to delay instrumentation until the profiler is connected. E.g. guarding against tracy::GetProfiler().IsConnected(). The telemetry context active state should be providing this exact guard, but that doesn't seem to cover all cases during early profiler startup.

ccp-serpent avatar Feb 27 '25 14:02 ccp-serpent