Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): stop logging expected zbus, Wayland window id and Hyprland remap messages as warnings (#3261)

Richie McIlroy515f418cfb0e
diff --git a/apps/desktop-gpui/patches/zed-wayland-visibility.patch b/apps/desktop-gpui/patches/zed-wayland-visibility.patch
index f25ceefcf..fbe7a8a8c 100644
--- a/apps/desktop-gpui/patches/zed-wayland-visibility.patch
+++ b/apps/desktop-gpui/patches/zed-wayland-visibility.patch
@@ -209,7 +209,7 @@
+ }
+ _ => return,
+ }
-+ log::warn!("no configure after remapping a window; replacing its toplevel role");
++ log::info!("no configure after remapping a window; replacing its toplevel role");
+ let xdg_surface =
+ state
+ .globals
diff --git a/apps/desktop-gpui/src/app_windows.rs b/apps/desktop-gpui/src/app_windows.rs
index b1aa564b7..30bc16d12 100644
--- a/apps/desktop-gpui/src/app_windows.rs
+++ b/apps/desktop-gpui/src/app_windows.rs
@@ -2843,7 +2843,13 @@ fn append_own_excluded_window_ids(
continue;
}
let Some(number) = window.number else {
- tracing::warn!(title, "excluded Cap window has no native window id");
+ // Wayland gives clients no window ids, so every Cap window lands
+ // here on every Linux Wayland recording.
+ if cfg!(target_os = "linux") {
+ tracing::debug!(title, "excluded Cap window has no native window id");
+ } else {
+ tracing::warn!(title, "excluded Cap window has no native window id");
+ }
continue;
};
let Ok(id) = number.to_string().parse::<scap_targets::WindowId>() else {
diff --git a/apps/desktop-gpui/src/main.rs b/apps/desktop-gpui/src/main.rs
index f4a441758..4a4cfaa41 100644
--- a/apps/desktop-gpui/src/main.rs
+++ b/apps/desktop-gpui/src/main.rs
@@ -158,6 +158,12 @@ fn end_windows_session() {
crash_capture::mark_clean_exit();
}
+/// zbus warns whenever a portal request object is gone before its
+/// properties are cached, which every finished portal request is; at `warn`
+/// that filled each Linux log with lines that say nothing.
+const DEFAULT_LOG_FILTER: &str =
+ "warn,cap_gpui=info,wgpu_core=error,wgpu_hal=error,zbus::proxy=error";
+
/// stdout, plus a rolling daily file the Feedback page can upload.
///
/// Mirrors `src-tauri/src/main.rs`: `tracing_appender::rolling::daily` into
@@ -173,7 +179,7 @@ fn init_logging() -> Option<tracing_appender::non_blocking::WorkerGuard> {
// matches nothing.
let filter = || {
tracing_subscriber::EnvFilter::try_from_default_env()
- .unwrap_or_else(|_| "warn,cap_gpui=info,wgpu_core=error,wgpu_hal=error".into())
+ .unwrap_or_else(|_| DEFAULT_LOG_FILTER.into())
};
let file = create_log_appender(&diagnostics::logs_dir(), diagnostics::LOG_FILE_PREFIX).map(
@@ -850,6 +856,7 @@ mod runtime_tests {
#[cfg(test)]
mod logging_tests {
use super::create_log_appender;
+ use tracing_subscriber::Layer as _;
use std::{io::Write, path::PathBuf};
struct LogDirectory(PathBuf);
@@ -873,6 +880,44 @@ mod logging_tests {
}
}
+ #[test]
+ fn the_default_filter_drops_zbus_property_cache_warnings_only() {
+ use std::sync::{Arc, Mutex};
+ use tracing_subscriber::layer::SubscriberExt as _;
+
+ #[derive(Clone, Default)]
+ struct Lines(Arc<Mutex<Vec<u8>>>);
+ impl Write for Lines {
+ fn write(&mut self, bytes: &[u8]) -> std::io::Result<usize> {
+ self.0.lock().unwrap().extend_from_slice(bytes);
+ Ok(bytes.len())
+ }
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+ }
+
+ let lines = Lines::default();
+ let writer = lines.clone();
+ let subscriber = tracing_subscriber::registry().with(
+ tracing_subscriber::fmt::layer()
+ .with_ansi(false)
+ .with_writer(move || writer.clone())
+ .with_filter(tracing_subscriber::EnvFilter::new(super::DEFAULT_LOG_FILTER)),
+ );
+ tracing::subscriber::with_default(subscriber, || {
+ tracing::warn!(target: "zbus::proxy", "Failed to populate properties cache");
+ tracing::error!(target: "zbus::proxy", "a zbus error still shows");
+ tracing::warn!(target: "zbus::connection", "other zbus warnings still show");
+ tracing::info!(target: "cap_gpui::session", "recording started");
+ });
+ let logged = String::from_utf8(lines.0.lock().unwrap().clone()).unwrap();
+ assert!(!logged.contains("Failed to populate properties cache"), "{logged}");
+ assert!(logged.contains("a zbus error still shows"), "{logged}");
+ assert!(logged.contains("other zbus warnings still show"), "{logged}");
+ assert!(logged.contains("recording started"), "{logged}");
+ }
+
#[test]
fn healthy_log_destination_preserves_existing_records() {
let directory = LogDirectory::new();