From 5698b45820eeb23a0619da09adebef16373d3134 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 1 Aug 2026 12:23:29 +0200 Subject: [PATCH] Hold worker data lock for the whole draw frame --- profiler/src/profiler/TracyView.cpp | 2 +- profiler/src/profiler/TracyView_ConnectionState.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/profiler/src/profiler/TracyView.cpp b/profiler/src/profiler/TracyView.cpp index 6480ab37..8214f1a4 100644 --- a/profiler/src/profiler/TracyView.cpp +++ b/profiler/src/profiler/TracyView.cpp @@ -339,6 +339,7 @@ static_assert( sizeof( CompressionName ) == sizeof( CompressionDesc ), "Unmatche bool View::Draw() { + Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread(); HandshakeStatus status = (HandshakeStatus)m_worker.GetHandshakeStatus(); switch( status ) { @@ -863,7 +864,6 @@ bool View::DrawImpl() ImGui::EndPopup(); } } - Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread(); auto& threadHints = m_worker.GetPendingThreadHints(); if( !threadHints.empty() ) { diff --git a/profiler/src/profiler/TracyView_ConnectionState.cpp b/profiler/src/profiler/TracyView_ConnectionState.cpp index bbbfe66b..812ee814 100644 --- a/profiler/src/profiler/TracyView_ConnectionState.cpp +++ b/profiler/src/profiler/TracyView_ConnectionState.cpp @@ -79,7 +79,6 @@ bool View::DrawConnection() FrameImage lastFrameImage{}; { - Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread(); ImGui::SameLine(); TextFocused( "+", RealToString( m_worker.GetSendInFlight() ) ); const auto sz = m_worker.GetFrameCount( *m_frames ); @@ -94,7 +93,7 @@ bool View::DrawConnection() TextFocused( "Frame time:", TimeToString( dt ) ); } const auto& fis = m_worker.GetFrameImages(); - // Keep a copy here since the worker may modify the frame images vector while we do not own the lock + // Keep a copy so the frame image data is retained independently of the worker storage. if( !fis.empty() ) lastFrameImage = *fis.back(); } @@ -130,7 +129,6 @@ bool View::DrawConnection() ImGui::SameLine( 0, 2 * ty ); const char* stopStr = ICON_FA_PLUG " Stop"; - Worker::MainThreadDataLockGuard lock = m_worker.ObtainLockForMainThread(); if( !m_disconnectIssued && m_worker.IsConnected() ) { if( ImGui::Button( stopStr ) )