Fastest and only macOS Dictation app with on-device STT and custom trained AI enhancement model. Windows, iOS testflight! Android, Linux waitlist open! A local Wispr Flow alternative. Follow https://x.com/fluidvoiceapp for more
perf(diagnostics): keep stop-path tracing out of Release
altic-deva5d32e6a2d5f
diff --git a/Sources/Fluid/ContentView.swift b/Sources/Fluid/ContentView.swiftindex e557f9cf..9cf47994 100644--- a/Sources/Fluid/ContentView.swift+++ b/Sources/Fluid/ContentView.swift@@ -4919,7 +4919,7 @@ extension ContentView {startMethod: AnalyticsOnboardingTryoutStartMethod = .hotkey) {DebugLogger.shared.debug("Begin dictation recording for slot \(slot.rawValue)", source: "ContentView")- DebugLogger.shared.info("CLOSE_DETAIL nextStartRequested uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL nextStartRequested uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")self.appBench("begin_recording slot=\(slot.rawValue) mode=\(mode.rawValue)")if self.isOnboardingVoicePlaygroundStepActive {self.asr.finalText = ""diff --git a/Sources/Fluid/Services/ASRService.swift b/Sources/Fluid/Services/ASRService.swiftindex 489a9d44..840aa20a 100644--- a/Sources/Fluid/Services/ASRService.swift+++ b/Sources/Fluid/Services/ASRService.swift@@ -1511,7 +1511,7 @@ final class ASRService: ObservableObject {reason: reason,recoveringRoute: self.isRecoveringAudioRoute)- DebugLogger.shared.info("CLOSE_DETAIL audioCallerResumed uptime=\(ProcessInfo.processInfo.systemUptime) awaitMs=\((ProcessInfo.processInfo.systemUptime - captureAwaitStartedAt) * 1000)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL audioCallerResumed uptime=\(ProcessInfo.processInfo.systemUptime) awaitMs=\((ProcessInfo.processInfo.systemUptime - captureAwaitStartedAt) * 1000)", source: "StopTiming")if report.status != noErr {DebugLogger.shared.warning("Direct Core Audio stop returned OSStatus \(report.status)",@@ -1531,7 +1531,7 @@ final class ASRService: ObservableObject {if let engine = self.engineStorage as? AVAudioEngine, engine.isRunning {engine.stop()}- DebugLogger.shared.info(+ DebugLogger.shared.debug("STOP_TRACE backend=audioEngine removeTapMs=\(Int((tapStopFinishedAt - tapStopStartedAt) * 1000)) engineStopMs=\(Int((ProcessInfo.processInfo.systemUptime - tapStopFinishedAt) * 1000))",source: "StopTiming")@@ -2841,7 +2841,7 @@ final class ASRService: ObservableObject {var tracePreviousAt = traceStartedAtfunc traceStop(_ phase: String) {let now = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info(+ DebugLogger.shared.debug("STOP_TRACE phase=\(phase) deltaMs=\(Int((now - tracePreviousAt) * 1000)) totalMs=\(Int((now - traceStartedAt) * 1000))",source: "StopTiming")diff --git a/Sources/Fluid/Services/DirectCoreAudioInput.swift b/Sources/Fluid/Services/DirectCoreAudioInput.swiftindex fdf53949..fbd1b3c5 100644--- a/Sources/Fluid/Services/DirectCoreAudioInput.swift+++ b/Sources/Fluid/Services/DirectCoreAudioInput.swift@@ -503,7 +503,7 @@ private final nonisolated class DirectCoreAudioInput: DirectCoreAudioInputControlet hardwareStoppedAt = ProcessInfo.processInfo.systemUptimefv_core_audio_capture_wake(capture)self.workerGroup.wait()- DebugLogger.shared.info(+ DebugLogger.shared.debug("STOP_TRACE backend=direct hardwareStopMs=\(Int((hardwareStoppedAt - stopStartedAt) * 1000)) workerDrainMs=\(Int((ProcessInfo.processInfo.systemUptime - hardwareStoppedAt) * 1000))",source: "StopTiming")@@ -1167,7 +1167,7 @@ final nonisolated class DirectCoreAudioLifecycleController: @unchecked Sendablelevel: .info)trace.mark("postStopState")- DebugLogger.shared.info("CLOSE_DETAIL audioContinuationResume uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL audioContinuationResume uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")return StopReport(status: status,droppedPackets: droppedPackets,diff --git a/Sources/Fluid/Services/GlobalHotkeyManager.swift b/Sources/Fluid/Services/GlobalHotkeyManager.swiftindex b0a4754a..1ccd4145 100644--- a/Sources/Fluid/Services/GlobalHotkeyManager.swift+++ b/Sources/Fluid/Services/GlobalHotkeyManager.swift@@ -2348,7 +2348,7 @@ final class GlobalHotkeyManager: NSObject {return false}guard !self.isProcessingStop else {- DebugLogger.shared.info("CLOSE_DETAIL shortcutRejected stopLocked=true uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL shortcutRejected stopLocked=true uptime=\(ProcessInfo.processInfo.systemUptime)", source: "StopTiming")return false}guard !self.asrService.isDictionaryTrainingCaptureActive else {@@ -2542,6 +2542,6 @@ private extension GlobalHotkeyManager {func traceStopUnlocked(since startedAt: TimeInterval) {self.isProcessingStop = false- DebugLogger.shared.info("CLOSE_DETAIL shortcutUnlocked uptime=\(ProcessInfo.processInfo.systemUptime) heldMs=\((ProcessInfo.processInfo.systemUptime - startedAt) * 1000)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL shortcutUnlocked uptime=\(ProcessInfo.processInfo.systemUptime) heldMs=\((ProcessInfo.processInfo.systemUptime - startedAt) * 1000)", source: "StopTiming")}}diff --git a/Sources/Fluid/Services/MenuBarManager.swift b/Sources/Fluid/Services/MenuBarManager.swiftindex 8e80fb92..a3653bf2 100644--- a/Sources/Fluid/Services/MenuBarManager.swift+++ b/Sources/Fluid/Services/MenuBarManager.swift@@ -133,7 +133,7 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {if isRunning {self.hasDeferredStoppedRecordingState = falseOverlayAudioLevelState.shared.isLive = true- DebugLogger.shared.info("WAVEFORM_LIVE", source: "StopTiming")+ DebugLogger.shared.debug("WAVEFORM_LIVE", source: "StopTiming")}self.isRecording = isRunningself.updateMenuBarIcon()@@ -497,18 +497,18 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {MainActor.assumeIsolated {let refreshStartedAt = ProcessInfo.processInfo.systemUptimeself?.flushDeferredStoppedRecordingState()- DebugLogger.shared.info(+ DebugLogger.shared.debug("HIDE_NOW postCommitMenuRefreshUs=\(Int((ProcessInfo.processInfo.systemUptime - refreshStartedAt) * 1_000_000))",source: "StopTiming")}}- DebugLogger.shared.info(+ DebugLogger.shared.debug("HIDE_NOW windowHideUs=\(Int((windowHideReturnedAt - startedAt) * 1_000_000)) " +"menuRefreshUs=\(Int((ProcessInfo.processInfo.systemUptime - windowHideReturnedAt) * 1_000_000))",source: "StopTiming")- DebugLogger.shared.info("STOP_TRACE phase=hide_dispatched closingAnimation=\(SettingsStore.shared.overlayClosingAnimationEnabled) elapsedMs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1000))", source: "StopTiming")+ DebugLogger.shared.debug("STOP_TRACE phase=hide_dispatched closingAnimation=\(SettingsStore.shared.overlayClosingAnimationEnabled) elapsedMs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1000))", source: "StopTiming")self.overlayBench("finish_hide_dispatched elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))")@@ -523,15 +523,15 @@ final class MenuBarManager: NSObject, ObservableObject, NSMenuDelegate {}let startedAt = ProcessInfo.processInfo.systemUptimeself.prepareForProcessingCompletion()- DebugLogger.shared.info("HIDE_TRACE phase=completion_prepared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=completion_prepared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")NotchOverlayManager.shared.setProcessing(false)- DebugLogger.shared.info("HIDE_TRACE phase=processing_cleared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=processing_cleared elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")self.overlayBench("finish_hide_request mode=awaited")let hideOutcome = await NotchOverlayManager.shared.hideAndWait()let hiddenAt = ProcessInfo.processInfo.systemUptimeself.flushDeferredStoppedRecordingState()- DebugLogger.shared.info(+ DebugLogger.shared.debug("STOP_TRACE phase=overlay_hidden hideMs=\(Int((hiddenAt - startedAt) * 1000)) menuRefreshMs=\(Int((ProcessInfo.processInfo.systemUptime - hiddenAt) * 1000))",source: "StopTiming")diff --git a/Sources/Fluid/Services/NotchOverlayManager.swift b/Sources/Fluid/Services/NotchOverlayManager.swiftindex 326ab168..d1c6c2ae 100644--- a/Sources/Fluid/Services/NotchOverlayManager.swift+++ b/Sources/Fluid/Services/NotchOverlayManager.swift@@ -417,12 +417,12 @@ final class NotchOverlayManager {// Stop monitoring active app changesActiveAppMonitor.shared.stopMonitoring()- DebugLogger.shared.info("HIDE_TRACE phase=monitor_stopped elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=monitor_stopped elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")// Hide bottom overlay if visibleif self.isBottomOverlayVisible {let bottomOutcome = await BottomOverlayWindowController.shared.hideAndWait()- DebugLogger.shared.info("HIDE_TRACE phase=bottom_returned elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=bottom_returned elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))", source: "StopTiming")guard bottomOutcome == .hidden else {Self.overlayBench("hide_return reason=bottom_superseded")return .supersededdiff --git a/Sources/Fluid/Views/BottomOverlayView.swift b/Sources/Fluid/Views/BottomOverlayView.swiftindex f93c6f9a..a859f672 100644--- a/Sources/Fluid/Views/BottomOverlayView.swift+++ b/Sources/Fluid/Views/BottomOverlayView.swift@@ -149,7 +149,7 @@ final class BottomOverlayWindowController {}self.window?.alphaValue = 1CATransaction.setCompletionBlock {- DebugLogger.shared.info(+ DebugLogger.shared.debug("SHOW_COMMIT elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))",source: "StopTiming")@@ -184,7 +184,7 @@ final class BottomOverlayWindowController {self.activeHideGeneration = currentGenerationlet visualStartedAt = ProcessInfo.processInfo.systemUptimeself.beginDismissalVisualIfPresented(generation: currentGeneration)- DebugLogger.shared.info("HIDE_TRACE phase=dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")Task { [weak self] inguard let self else { return }let outcome = await self.performHideAndWait(generation: currentGeneration)@@ -209,7 +209,7 @@ final class BottomOverlayWindowController {MainActor.assumeIsolated {guard let self, self.presentationGeneration == generation else { return }self.window?.alphaValue = 0- DebugLogger.shared.info(+ DebugLogger.shared.debug("EXIT_DONE elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))",source: "StopTiming")@@ -276,7 +276,7 @@ final class BottomOverlayWindowController {// ignoresMouseEvents fence can never delay the visual removal.CATransaction.setCompletionBlock { [weak self] inMainActor.assumeIsolated {- DebugLogger.shared.info(+ DebugLogger.shared.debug("HIDE_COMMIT elapsedMs=\(Int(((ProcessInfo.processInfo.systemUptime - startedAt) * 1000).rounded()))",source: "StopTiming")@@ -288,7 +288,7 @@ final class BottomOverlayWindowController {self.scheduleIgnoreMouseEventsAfterHide()}}- DebugLogger.shared.info(+ DebugLogger.shared.debug("HIDE_NOW hideUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000)) " +"windowVisible=\(self.window?.isVisible == true)",source: "StopTiming"@@ -309,7 +309,7 @@ final class BottomOverlayWindowController {guard let self, self.window?.alphaValue == 0 else { return }let startedAt = ProcessInfo.processInfo.systemUptimeself.window?.ignoresMouseEvents = true- DebugLogger.shared.info(+ DebugLogger.shared.debug("HIDE_NOW deferredIgnoreMouseUs=\(Int((ProcessInfo.processInfo.systemUptime - startedAt) * 1_000_000))",source: "StopTiming")@@ -355,7 +355,7 @@ final class BottomOverlayWindowController {self.activeHideGeneration = currentGenerationlet visualStartedAt = ProcessInfo.processInfo.systemUptimeself.beginDismissalVisualIfPresented(generation: currentGeneration)- DebugLogger.shared.info("HIDE_TRACE phase=awaited_dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=awaited_dismissal_state elapsedUs=\(Int((ProcessInfo.processInfo.systemUptime - visualStartedAt) * 1_000_000))", source: "StopTiming")let outcome = await self.performHideAndWait(generation: currentGeneration)self.completeHideOperation(generation: currentGeneration, outcome: outcome)return outcome@@ -385,7 +385,7 @@ final class BottomOverlayWindowController {var previousTraceTime = startedAtfunc traceHide(_ phase: String) {let now = ProcessInfo.processInfo.systemUptime- DebugLogger.shared.info("HIDE_TRACE phase=\(phase) deltaUs=\(Int((now - previousTraceTime) * 1_000_000)) totalUs=\(Int((now - startedAt) * 1_000_000))", source: "StopTiming")+ DebugLogger.shared.debug("HIDE_TRACE phase=\(phase) deltaUs=\(Int((now - previousTraceTime) * 1_000_000)) totalUs=\(Int((now - startedAt) * 1_000_000))", source: "StopTiming")previousTraceTime = now}Self.overlayBench("bottom_hide_start windowExists=\(self.window != nil)")@@ -761,7 +761,7 @@ final class BottomOverlayWindowController {)let originStartedAt = ProcessInfo.processInfo.systemUptimewindow.setFrameOrigin(edge)- DebugLogger.shared.info(+ DebugLogger.shared.debug("HIDE_TRACE phase=parking_detail accessibilityUs=\(Int((accessibilityClearedAt - parkingStartedAt) * 1_000_000)) " +"geometryUs=\(Int((originStartedAt - accessibilityClearedAt) * 1_000_000)) " +"setOriginUs=\(Int((ProcessInfo.processInfo.systemUptime - originStartedAt) * 1_000_000))",diff --git a/Sources/Fluid/Views/OverlayCloseDiagnostics.swift b/Sources/Fluid/Views/OverlayCloseDiagnostics.swiftindex f88efb0f..d563b2f8 100644--- a/Sources/Fluid/Views/OverlayCloseDiagnostics.swift+++ b/Sources/Fluid/Views/OverlayCloseDiagnostics.swift@@ -18,9 +18,10 @@ struct OverlayCloseTrace {}mutating func finish() {+ guard DebugLogger.diagnosticsEnabled else { return }let total = (ProcessInfo.processInfo.systemUptime - self.startedAt) * 1000let fields = self.checkpoints.map { "\($0.0)Ms=\(String(format: "%.3f", $0.1))" }.joined(separator: " ")- DebugLogger.shared.info("CLOSE_DETAIL scope=\(self.name) uptime=\(self.startedAt) totalMs=\(String(format: "%.3f", total)) \(fields)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL scope=\(self.name) uptime=\(self.startedAt) totalMs=\(String(format: "%.3f", total)) \(fields)", source: "StopTiming")}}@@ -31,13 +32,13 @@ enum OverlayCloseRunLoopProbe {private static var observer: CFRunLoopObserver?static func begin() {- guard self.observer == nil else { return }+ guard DebugLogger.diagnosticsEnabled, self.observer == nil else { return }let state = ProbeState()guard let observer = CFRunLoopObserverCreateWithHandler(nil, CFRunLoopActivity.allActivities.rawValue, true, 0, { _, activity inlet now = ProcessInfo.processInfo.systemUptimelet elapsed = (now - state.previousAt) * 1000if state.previousPhase != CFRunLoopActivity.beforeWaiting.rawValue, elapsed > 8 {- DebugLogger.shared.info("CLOSE_DETAIL runLoop fromPhase=\(state.previousPhase) toPhase=\(activity.rawValue) startUptime=\(state.previousAt) occupiedMs=\(elapsed)", source: "StopTiming")+ DebugLogger.shared.debug("CLOSE_DETAIL runLoop fromPhase=\(state.previousPhase) toPhase=\(activity.rawValue) startUptime=\(state.previousAt) occupiedMs=\(elapsed)", source: "StopTiming")}state.previousAt = nowstate.previousPhase = activity.rawValue