From 63971262f8954acd1fdcab99df4793d06a25dd46 Mon Sep 17 00:00:00 2001 From: brianp Date: Wed, 15 Jan 2025 12:14:10 +0100 Subject: [PATCH] Fix gpuminer initialization The GPU miner hardware monitor was being initialized too early causing the app never to recognize the gpu miner later on. Fix the initialization sequence, and only append the gpu miner data to telemetry on demand instead of on telemetry initialization. --- src-tauri/src/main.rs | 21 +++++++++++---------- src-tauri/src/telemetry_service.rs | 16 ++++++++-------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index caa473121..a56582140 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -239,16 +239,6 @@ async fn setup_inner( let last_binaries_update_timestamp = state.config.read().await.last_binaries_update_timestamp(); let now = SystemTime::now(); - let _unused = state - .gpu_miner - .write() - .await - .detect(config_dir.clone()) - .await - .inspect_err(|e| error!(target: LOG_TARGET, "Could not detect gpu miner: {:?}", e)); - - HardwareStatusMonitor::current().initialize().await?; - state .telemetry_manager .write() @@ -457,6 +447,17 @@ async fn setup_inner( //drop binary resolver to release the lock drop(binary_resolver); + let _unused = state + .gpu_miner + .write() + .await + .detect(config_dir.clone()) + .await + .inspect_err(|e| error!(target: LOG_TARGET, "Could not detect gpu miner: {:?}", e)); + + HardwareStatusMonitor::current().initialize().await?; + + let mut tor_control_port = None; if use_tor && !cfg!(target_os = "macos") { state diff --git a/src-tauri/src/telemetry_service.rs b/src-tauri/src/telemetry_service.rs index 702959457..650a8db3c 100644 --- a/src-tauri/src/telemetry_service.rs +++ b/src-tauri/src/telemetry_service.rs @@ -104,11 +104,6 @@ impl TelemetryService { Some(cpu) => cpu.public_properties.name.clone(), None => "Unknown".to_string(), }; - let gpu_name = hardware.get_gpu_devices().await?; - let gpu_name = match gpu_name.first() { - Some(gpu) => gpu.public_properties.name.clone(), - None => "Unknown".to_string(), - }; let os = PlatformUtils::detect_current_os(); self.version = app_version; @@ -130,7 +125,6 @@ impl TelemetryService { version, user_id: user, cpu_name, - gpu_name, os, }; tokio::select! { @@ -196,7 +190,6 @@ struct SystemInfo { user_id: String, os: CurrentOperatingSystem, cpu_name: String, - gpu_name: String, } async fn send_telemetry_data( @@ -206,6 +199,13 @@ async fn send_telemetry_data( ) -> Result<(), TelemetryServiceError> { let request = reqwest::Client::new(); + let hardware = HardwareStatusMonitor::current(); + let gpu_name = hardware.get_gpu_devices().await?; + let gpu_name = match gpu_name.first() { + Some(gpu) => gpu.public_properties.name.clone(), + None => "Unknown".to_string(), + }; + let full_data = FullTelemetryData { event_name: data.event_name, event_value: data.event_value, @@ -215,7 +215,7 @@ async fn send_telemetry_data( version: system_info.version, os: system_info.os.to_string(), cpu_name: system_info.cpu_name, - gpu_name: system_info.gpu_name, + gpu_name, }; let request_builder = request .post(api_url)