From f005960bdc3cd6af768347990322771c5b57af0d Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 6 Jul 2026 11:34:03 -0700 Subject: [PATCH] Improve backtrace trimming for cranelift (#8294) When using the cranelift backend we would get stack traces that would contain a lot of egui callstacks. This should solve it. --- crates/egui/src/callstack.rs | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/callstack.rs b/crates/egui/src/callstack.rs index b1239db01..6b0c35380 100644 --- a/crates/egui/src/callstack.rs +++ b/crates/egui/src/callstack.rs @@ -88,16 +88,36 @@ pub fn capture() -> String { return false; } - // Remove stuff that isn't user calls: + // Remove frames that are part of egui itself, since they are not useful to the user. + let skip_crates = [ + "alloc", + "backtrace", + "core", + "eframe", + "egui_extras", + "egui_plot", + "egui", + "epaint", + "std", + "winit", + ]; + for crate_name in skip_crates { + let name = frame.name.trim_start_matches('<'); + if name.starts_with(crate_name) + && name + .as_bytes() + .get(crate_name.len()) + .copied() + .is_none_or(|b| b.is_ascii_punctuation() && b != b'_') + { + return false; + } + } + let skip_prefixes = [ // "backtrace::", // not needed, since we cut at egui::callstack::capture - "egui::", - "", - "egui_plot::", - "egui_extras::", "core::ptr::drop_in_place", - "eframe::", "core::ops::function::FnOnce::call_once", " as core::ops::function::FnOnce>::call_once", ];