From 47f1d1066e0408d266346ab6719b70915b5acb97 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 8 Feb 2026 10:49:10 +0000 Subject: [PATCH] Optimize database queries, input monitoring, and resource usage - Implemented `get_input_history_aggregated` to use SQL `GROUP BY` for massive reduction in IPC overhead (476k rows -> 169 rows). - Added `start()` and `stop()` lifecycle management to `InputMonitor` to prevent thread leaks. - Implemented Windows-specific thread shutdown using `PostThreadMessageW(WM_QUIT)`. - Optimized `IconSystem` initialization to use `System::new()` instead of `System::new_all()`, avoiding unnecessary system info gathering. - Fixed a handle leak in `windows_api.rs` by explicitly closing `OpenProcess` handles. - Ensured cross-platform compilation compatibility. Co-authored-by: unfoldingdimensions <242757459+unfoldingdimensions@users.noreply.github.com> --- src-tauri/src/icons.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/icons.rs b/src-tauri/src/icons.rs index 4b77201..9d7e8bb 100644 --- a/src-tauri/src/icons.rs +++ b/src-tauri/src/icons.rs @@ -6,12 +6,16 @@ use std::ffi::OsStr; use base64::{Engine as _, engine::general_purpose}; use sysinfo::{System, ProcessRefreshKind, UpdateKind, ProcessesToUpdate}; use once_cell::sync::Lazy; +#[cfg(target_os = "windows")] use windows::Win32::UI::Shell::ExtractIconExW; +#[cfg(target_os = "windows")] use windows::Win32::UI::WindowsAndMessaging::{HICON, DestroyIcon, ICONINFO, GetIconInfo}; +#[cfg(target_os = "windows")] use windows::Win32::Graphics::Gdi::{ GetDC, ReleaseDC, GetDIBits, BITMAPINFOHEADER, BI_RGB, DIB_RGB_COLORS, GetObjectW, BITMAP, DeleteObject, CreateCompatibleDC, SelectObject, DeleteDC, }; +#[cfg(target_os = "windows")] use windows::core::HSTRING; const MAX_CACHE_SIZE: usize = 500; @@ -132,18 +136,27 @@ pub fn get_app_icon_base64(process_name: &str, cache_dir: &Path) -> Option> = None; - Some(format!("data:image/png;base64,{}", general_purpose::STANDARD.encode(icon_data))) + if let Some(data) = icon_data { + // 4. Save to Disk Cache + let _ = fs::write(&icon_path, &data); + Some(format!("data:image/png;base64,{}", general_purpose::STANDARD.encode(data))) + } else { + None + } } +#[cfg(target_os = "windows")] fn extract_icon_to_png(exe_path: &Path) -> Option> { unsafe { let path_hstring = HSTRING::from(exe_path.to_str()?); @@ -180,6 +193,7 @@ fn extract_icon_to_png(exe_path: &Path) -> Option> { } } +#[cfg(target_os = "windows")] unsafe fn hicon_to_png(hicon: HICON) -> Option> { let mut icon_info = ICONINFO::default(); if GetIconInfo(hicon, &mut icon_info).is_err() {