From fc025b248d66b0aa6aacd2dc0dfa48d25b5f82d4 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 19:06:18 -0700 Subject: [PATCH] Revert "Introduce a new `ToggleGraphicsProfiler` command (#7607)" (cherry-pick #8567) (#8570) Cherry-picked Revert "Introduce a new `ToggleGraphicsProfiler` command (#7607)" (#8567) This reverts commit 0cebf68306ab0ef08693701532260e1fdc0f1ee9. Although this thing is very cool, it is a top source of crashes. Example crash: ``` Segmentation fault: 11 on thread 26 objc_retain +16 invocation function for block in Overlay::onCommandBufferCommit(id) +60 MTLDispatchListApply +52 ``` Release Notes: - Removed "Toggle Graphics Profiler" as it crashes too much. Co-authored-by: Conrad Irwin --- crates/gpui/src/platform.rs | 2 +- .../gpui/src/platform/linux/wayland/window.rs | 4 ---- crates/gpui/src/platform/linux/x11/window.rs | 4 ---- crates/gpui/src/platform/mac/window.rs | 21 ------------------- crates/gpui/src/platform/test/window.rs | 2 -- crates/gpui/src/window.rs | 10 --------- crates/workspace/src/workspace.rs | 2 -- crates/zed/resources/info/Permissions.plist | 2 -- crates/zed/src/app_menus.rs | 4 ---- 9 files changed, 1 insertion(+), 50 deletions(-) diff --git a/crates/gpui/src/platform.rs b/crates/gpui/src/platform.rs index bbd2e93b4fe03eabf81df517eba7279a004c55f8..e02fadbabc0177300ffa3e0548a27baedb4b72f4 100644 --- a/crates/gpui/src/platform.rs +++ b/crates/gpui/src/platform.rs @@ -192,8 +192,8 @@ pub(crate) trait PlatformWindow: HasWindowHandle + HasDisplayHandle { fn on_appearance_changed(&self, callback: Box); fn is_topmost_for_position(&self, position: Point) -> bool; fn draw(&self, scene: &Scene); + fn sprite_atlas(&self) -> Arc; - fn set_graphics_profiler_enabled(&self, enabled: bool); #[cfg(any(test, feature = "test-support"))] fn as_test(&mut self) -> Option<&mut TestWindow> { diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 5f0b64cff71efff55214de69ad39b92d1032a4d9..ca50c9846461ccdf00939a5c4feed5e5557d1e21 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -390,10 +390,6 @@ impl PlatformWindow for WaylandWindow { let inner = self.0.inner.lock(); inner.renderer.sprite_atlas().clone() } - - fn set_graphics_profiler_enabled(&self, enabled: bool) { - //todo!(linux) - } } #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] diff --git a/crates/gpui/src/platform/linux/x11/window.rs b/crates/gpui/src/platform/linux/x11/window.rs index e4293d7b9df9b6969e99b3dd05d1cc23695aea76..0d7c84e7cb7aaf34c6e11c35ea6c52cbd89a8600 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -513,8 +513,4 @@ impl PlatformWindow for X11Window { let inner = self.0.inner.lock(); inner.renderer.sprite_atlas().clone() } - - fn set_graphics_profiler_enabled(&self, enabled: bool) { - unimplemented!("linux") - } } diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 0773b156bd4402667652cffb00320c219642358e..bdfd41a46f792e7a9fdd6cc8b6283680091fc898 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1060,27 +1060,6 @@ impl PlatformWindow for MacWindow { fn sprite_atlas(&self) -> Arc { self.0.lock().renderer.sprite_atlas().clone() } - - /// Enables or disables the Metal HUD for debugging purposes. Note that this only works - /// when the app is bundled and it has the `MetalHudEnabled` key set to true in Info.plist. - fn set_graphics_profiler_enabled(&self, enabled: bool) { - let this_lock = self.0.lock(); - let layer = this_lock.renderer.layer(); - - unsafe { - if enabled { - let hud_properties = NSDictionary::dictionaryWithObject_forKey_( - nil, - ns_string("default"), - ns_string("mode"), - ); - let _: () = msg_send![layer, setDeveloperHUDProperties: hud_properties]; - } else { - let _: () = - msg_send![layer, setDeveloperHUDProperties: NSDictionary::dictionary(nil)]; - } - } - } } impl HasWindowHandle for MacWindow { diff --git a/crates/gpui/src/platform/test/window.rs b/crates/gpui/src/platform/test/window.rs index 49ce7bd771a864985466de25d18cfc3da02d10ae..70dcce9033b8e9a41022e3e31b1ec264ffbaac26 100644 --- a/crates/gpui/src/platform/test/window.rs +++ b/crates/gpui/src/platform/test/window.rs @@ -251,8 +251,6 @@ impl PlatformWindow for TestWindow { self.0.lock().sprite_atlas.clone() } - fn set_graphics_profiler_enabled(&self, _enabled: bool) {} - fn as_test(&mut self) -> Option<&mut TestWindow> { Some(self) } diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index 65a7766b7b3b72b07546641e3ec02ad3c934a255..09c78f64fe1a6c9e9776e3265a018ee797c419f4 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -280,7 +280,6 @@ pub struct Window { pub(crate) focus: Option, focus_enabled: bool, pending_input: Option, - graphics_profiler_enabled: bool, } #[derive(Default, Debug)] @@ -474,7 +473,6 @@ impl Window { focus: None, focus_enabled: true, pending_input: None, - graphics_profiler_enabled: false, } } fn new_focus_listener( @@ -1499,14 +1497,6 @@ impl<'a> WindowContext<'a> { } } - /// Toggle the graphics profiler to debug your application's rendering performance. - pub fn toggle_graphics_profiler(&mut self) { - self.window.graphics_profiler_enabled = !self.window.graphics_profiler_enabled; - self.window - .platform_window - .set_graphics_profiler_enabled(self.window.graphics_profiler_enabled); - } - /// Register the given handler to be invoked whenever the global of the given type /// is updated. pub fn observe_global( diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 28f15b3e967ebe028a41bc254e1c1187203a86b7..b18590a334bc31f98ced6f6b289cd79beec13d42 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -122,7 +122,6 @@ actions!( ToggleRightDock, ToggleBottomDock, CloseAllDocks, - ToggleGraphicsProfiler, ] ); @@ -3560,7 +3559,6 @@ impl Workspace { workspace.reopen_closed_item(cx).detach(); }), ) - .on_action(|_: &ToggleGraphicsProfiler, cx| cx.toggle_graphics_profiler()) } #[cfg(any(test, feature = "test-support"))] diff --git a/crates/zed/resources/info/Permissions.plist b/crates/zed/resources/info/Permissions.plist index fd608afaa0c3252e1dba3529fb67e839d93e4280..bded5a82e2c81d811b8186dde97736170a74b425 100644 --- a/crates/zed/resources/info/Permissions.plist +++ b/crates/zed/resources/info/Permissions.plist @@ -22,5 +22,3 @@ An application in Zed wants to use speech recognition. NSRemindersUsageDescription An application in Zed wants to use your reminders. -MetalHudEnabled - diff --git a/crates/zed/src/app_menus.rs b/crates/zed/src/app_menus.rs index 15cc17620beb1f6cd4c7a7a179d90f0cfb3589aa..6d75c86862caf9dc9808a6d883abae0e9dcfe6aa 100644 --- a/crates/zed/src/app_menus.rs +++ b/crates/zed/src/app_menus.rs @@ -156,10 +156,6 @@ pub fn app_menus() -> Vec> { MenuItem::action("View Telemetry", crate::OpenTelemetryLog), MenuItem::action("View Dependency Licenses", crate::OpenLicenses), MenuItem::action("Show Welcome", workspace::Welcome), - MenuItem::action( - "Toggle Graphics Profiler", - workspace::ToggleGraphicsProfiler, - ), MenuItem::separator(), MenuItem::separator(), MenuItem::action(