From 36b4f765fd7ee5ea1644827497866ebaf5e771dd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Feb 2026 03:46:24 +0000 Subject: [PATCH] Improve code quality: use named constant and clearer error logs - Extract 0.1 second delay to named constant 'registrationDelay' with explanatory comment - Split error message into separate log lines for better readability Co-authored-by: rustdesk <71636191+rustdesk@users.noreply.github.com> --- flutter/macos/Runner/MainFlutterWindow.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flutter/macos/Runner/MainFlutterWindow.swift b/flutter/macos/Runner/MainFlutterWindow.swift index 53dec2742..8572d5a82 100644 --- a/flutter/macos/Runner/MainFlutterWindow.swift +++ b/flutter/macos/Runner/MainFlutterWindow.swift @@ -229,12 +229,15 @@ class MainFlutterWindow: NSWindow { captureSession.commitConfiguration() // Start and immediately stop the session to trigger registration captureSession.startRunning() - // Keep a strong reference and stop after a brief moment - DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) { [captureSession] in + // Minimum delay required for macOS to register the app in System Settings + let registrationDelay: TimeInterval = 0.1 + // Keep a strong reference and stop after the registration delay + DispatchQueue.main.asyncAfter(deadline: .now() + registrationDelay) { [captureSession] in captureSession.stopRunning() } } catch { - NSLog("[RustDesk] Error creating audio capture session for permission registration: %@. The app may not appear in System Settings > Privacy & Security > Microphone. Please verify permissions manually.", error.localizedDescription) + NSLog("[RustDesk] Failed to create audio capture session: %@", error.localizedDescription) + NSLog("[RustDesk] The app may not appear in System Settings > Privacy & Security > Microphone") } } }