Skip to content

Open source CapCut alternative.

TypeScript

Increase vision parse timeout and add debug timing logs

David Le558462906951
diff --git a/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift b/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift
index 2958801a..16fd6609 100644
--- a/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift
+++ b/apps/Donkey/Sources/Donkey/LocalUIElementDetection/DebugUIInspectionCoordinator.swift
@@ -623,9 +623,14 @@ final class DebugUIInspectionCoordinator {
continue
}
do {
+ DebugUIInspectionLog.overlay.info(
+ "debug inspection vision request sending windowID=\(windowID, privacy: .public) captureBytes=\(capture.parseImageData.count, privacy: .public)"
+ )
+ let requestStart = Date()
let response = try await client.parseScreenshotVision(
imageData: capture.parseImageData
)
+ let elapsedMs = Int(Date().timeIntervalSince(requestStart) * 1000)
let parsedElements = VisionParseDebugUIOverlayMapper.frame(
from: response,
target: capture.target,
@@ -633,7 +638,7 @@ final class DebugUIInspectionCoordinator {
minConfidence: currentConfig.minConfidence
).elements
DebugUIInspectionLog.overlay.info(
- "debug inspection vision parsed windowID=\(windowID, privacy: .public) responseElements=\(response.elements.count, privacy: .public) mappedElements=\(parsedElements.count, privacy: .public) minConfidence=\(self.currentConfig.minConfidence, privacy: .public) responseImage=\(Int(response.image.width), privacy: .public)x\(Int(response.image.height), privacy: .public) captureBytes=\(capture.parseImageData.count, privacy: .public)"
+ "debug inspection vision parsed windowID=\(windowID, privacy: .public) elapsedMs=\(elapsedMs, privacy: .public) responseElements=\(response.elements.count, privacy: .public) mappedElements=\(parsedElements.count, privacy: .public) minConfidence=\(self.currentConfig.minConfidence, privacy: .public) responseImage=\(Int(response.image.width), privacy: .public)x\(Int(response.image.height), privacy: .public) captureBytes=\(capture.parseImageData.count, privacy: .public)"
)
elements.removeAll { Self.windowID(for: $0) == windowID }
elements += parsedElements
diff --git a/apps/Donkey/Sources/DonkeyAI/DonkeyBackendInferenceClient.swift b/apps/Donkey/Sources/DonkeyAI/DonkeyBackendInferenceClient.swift
index b04bb377..2f61e4a9 100644
--- a/apps/Donkey/Sources/DonkeyAI/DonkeyBackendInferenceClient.swift
+++ b/apps/Donkey/Sources/DonkeyAI/DonkeyBackendInferenceClient.swift
@@ -280,6 +280,10 @@ public struct DonkeyBackendInferenceClient: @unchecked Sendable {
) async throws -> RemoteVisionParseResponse {
var request = makeRequest(path: "/api/inference/vision")
request.httpMethod = "POST"
+ // OmniParser on a cold/slow RunPod worker can take ~60s, which sits right
+ // on URLSession's default 60s request timeout. Give the parse room to land
+ // so a slow-but-successful response isn't killed at the boundary.
+ request.timeoutInterval = 180
request.httpBody = try JSONEncoder().encode(
RemoteVisionParseRequest(
image: imageData.base64EncodedString(),