From b0eb8ad8c80094de34abd88c109aea421461622b Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Wed, 19 Aug 2026 11:01:20 +0300 Subject: [PATCH] Properly shutdown Tracy in on-demand mode Avoids the abrupt connection termination warning in Tracy. --- src/main.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main.rs b/src/main.rs index e80992ee..8878b56e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,6 +143,11 @@ fn main() -> Result<(), Box> { // slow. tracy_client::Client::start(); + // In on-demand mode, we must shut down Tracy manually to terminate the connection cleanly. + // Do it from a Drop impl here, so that it runs after the Drop code for all of the state created + // below, because some of those Drop impls themselves create Tracy spans. + let _shutdown_tracy = ShutdownTracy; + info!("starting version {}", &version()); // Load the config. @@ -408,3 +413,13 @@ fn set_default_max_buffer_size(display: &Display, size: usize) { libc::dlclose(lib); } } + +struct ShutdownTracy; +impl Drop for ShutdownTracy { + fn drop(&mut self) { + #[cfg(feature = "profile-with-tracy-ondemand")] + unsafe { + tracy_client::sys::___tracy_shutdown_profiler(); + } + } +} -- knotmirror 0.0.1