YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix(screen): drain SCK window enumeration autorelease objects (#4793)
Louis Beaumontce66aa3626c7
diff --git a/crates/screenpipe-screen/src/capture_screenshot_by_window.rs b/crates/screenpipe-screen/src/capture_screenshot_by_window.rsindex 70886edc1..f23bd03d5 100644--- a/crates/screenpipe-screen/src/capture_screenshot_by_window.rs+++ b/crates/screenpipe-screen/src/capture_screenshot_by_window.rs@@ -311,6 +311,7 @@ impl WindowFilters {}/// Intermediate structure for window data extracted from platform-specific Window types+#[cfg_attr(target_os = "macos", derive(Clone))]struct WindowData {app_name: String,title: String,@@ -634,11 +635,16 @@ fn get_all_windows() -> Result<Vec<WindowData>, Box<dyn Error>> {#[cfg(target_os = "macos")]fn get_all_windows_sck() -> Result<Vec<WindowData>, Box<dyn Error>> {- let windows = SckWindow::all()?;- Ok(windows- .into_iter()- .filter_map(extract_window_data_sck)- .collect())+ let result: Result<Vec<WindowData>, String> = cidre::objc::ar_pool(|| {+ let windows = SckWindow::all().map_err(|e| e.to_string())?;+ Ok(windows+ .into_iter()+ .filter_map(extract_window_data_sck)+ .collect())+ });++ result+ .map_err(|e| Box::new(std::io::Error::new(std::io::ErrorKind::Other, e)) as Box<dyn Error>)}#[cfg(target_os = "macos")]@@ -913,8 +919,28 @@ pub fn get_excluded_sck_window_ids(window_filters: &WindowFilters) -> Vec<u32> {return Vec::new();}- let windows = match SckWindow::all() {- Ok(w) => w,+ let excluded = match cidre::objc::ar_pool(|| -> Result<Vec<u32>, String> {+ let windows = SckWindow::all().map_err(|e| e.to_string())?;+ let mut excluded = Vec::new();++ for w in &windows {+ let app_name = w.app_name().unwrap_or_default();+ let title = w.title().unwrap_or_default();++ if app_name.is_empty() {+ continue;+ }++ if !window_filters.is_valid(&app_name, &title) {+ if let Ok(id) = w.id() {+ excluded.push(id);+ }+ }+ }++ Ok(excluded)+ }) {+ Ok(ids) => ids,Err(e) => {debug!("get_excluded_sck_window_ids: failed to enumerate windows: {}",@@ -924,22 +950,6 @@ pub fn get_excluded_sck_window_ids(window_filters: &WindowFilters) -> Vec<u32> {}};- let mut excluded = Vec::new();- for w in &windows {- let app_name = w.app_name().unwrap_or_default();- let title = w.title().unwrap_or_default();-- if app_name.is_empty() {- continue;- }-- if !window_filters.is_valid(&app_name, &title) {- if let Ok(id) = w.id() {- excluded.push(id);- }- }- }-if !excluded.is_empty() {debug!("resolved {} ignored window(s) to SCK IDs: {:?}",