diff --git a/apps/ios/Sources/Location/LocationService.swift b/apps/ios/Sources/Location/LocationService.swift index 320a5ab38..3c1a80516 100644 --- a/apps/ios/Sources/Location/LocationService.swift +++ b/apps/ios/Sources/Location/LocationService.swift @@ -86,9 +86,9 @@ final class LocationService: NSObject, CLLocationManagerDelegate { } } - private func withTimeout( + private func withTimeout( timeoutMs: Int, - operation: @escaping () async throws -> T) async throws -> T + operation: @escaping @Sendable () async throws -> T) async throws -> T { if timeoutMs == 0 { return try await operation() @@ -117,26 +117,35 @@ final class LocationService: NSObject, CLLocationManagerDelegate { } } - func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { - if let cont = self.authContinuation { - self.authContinuation = nil - cont.resume(returning: manager.authorizationStatus) + nonisolated func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { + let status = manager.authorizationStatus + Task { @MainActor in + if let cont = self.authContinuation { + self.authContinuation = nil + cont.resume(returning: status) + } } } - func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { - guard let cont = self.locationContinuation else { return } - self.locationContinuation = nil - if let latest = locations.last { - cont.resume(returning: latest) - } else { - cont.resume(throwing: Error.unavailable) + nonisolated func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { + let locs = locations + Task { @MainActor in + guard let cont = self.locationContinuation else { return } + self.locationContinuation = nil + if let latest = locs.last { + cont.resume(returning: latest) + } else { + cont.resume(throwing: Error.unavailable) + } } } - func locationManager(_ manager: CLLocationManager, didFailWithError error: Swift.Error) { - guard let cont = self.locationContinuation else { return } - self.locationContinuation = nil - cont.resume(throwing: error) + nonisolated func locationManager(_ manager: CLLocationManager, didFailWithError error: Swift.Error) { + let err = error + Task { @MainActor in + guard let cont = self.locationContinuation else { return } + self.locationContinuation = nil + cont.resume(throwing: err) + } } } diff --git a/apps/ios/Sources/Voice/TalkModeManager.swift b/apps/ios/Sources/Voice/TalkModeManager.swift index ce992290d..943f18604 100644 --- a/apps/ios/Sources/Voice/TalkModeManager.swift +++ b/apps/ios/Sources/Voice/TalkModeManager.swift @@ -288,9 +288,8 @@ final class TalkModeManager: NSObject { self.chatSubscribedSessionKeys.insert(key) self.logger.info("chat.subscribe ok sessionKey=\(key, privacy: .public)") } catch { - self.logger.warning( - "chat.subscribe failed sessionKey=\(key, privacy: .public) " + - "err=\(error.localizedDescription, privacy: .public)") + let err = error.localizedDescription + self.logger.warning("chat.subscribe failed key=\(key, privacy: .public) err=\(err, privacy: .public)") } } @@ -528,9 +527,8 @@ final class TalkModeManager: NSObject { self.lastPlaybackWasPCM = false result = await self.mp3Player.play(stream: stream) } - self.logger.info( - "elevenlabs stream finished=\(result.finished, privacy: .public) " + - "dur=\(Date().timeIntervalSince(started), privacy: .public)s") + let duration = Date().timeIntervalSince(started) + self.logger.info("elevenlabs stream finished=\(result.finished, privacy: .public) dur=\(duration, privacy: .public)s") if !result.finished, let interruptedAt = result.interruptedAt { self.lastInterruptedAtSeconds = interruptedAt }