Run a virtual iPhone on an Apple Silicon Mac.
Swift
Run vphoned requests concurrently to keep controls responsive
Lakr300039456768
diff --git a/Research/vphoned_http_api.md b/Research/vphoned_http_api.mdindex a308d798..ad437732 100644--- a/Research/vphoned_http_api.md+++ b/Research/vphoned_http_api.md@@ -53,8 +53,11 @@ receive pong frames. JSON WebSocket frames are limited to 1 MiB afterfragment reassembly.SwiftNIO handles parsing, upgrade, masking, and backpressure. IcliKit 0.6.1-owns general device operations; they run on a serial worker queue because its-in-process bridge is synchronous. The vphone-specific IPA signing and all-app+owns general device operations. Each HTTP or WebSocket request runs independently+on a concurrent worker queue, so a stalled system service does not block HID,+file browsing, or unrelated requests. The host serializes the input events it+sends so touch and key sequences retain their order. State polling uses its own+worker queue. The vphone-specific IPA signing and all-appkeychain view remain in native Objective-C modules. The VM GUI uses HTTP overVSOCK 1339 directly; host TCP forwarding is opt-in. The former length-prefixedVSOCK 1337 protocol and duplicate ObjC command handlers have been removed.diff --git a/VPhoneDaemon/Daemon/GuestAPI.swift b/VPhoneDaemon/Daemon/GuestAPI.swiftindex 394a78a7..9e7a33ee 100644--- a/VPhoneDaemon/Daemon/GuestAPI.swift+++ b/VPhoneDaemon/Daemon/GuestAPI.swift@@ -21,9 +21,10 @@ enum GuestAPIError: Error, CustomStringConvertible {/// IcliKit owns general device work; only vphone-specific installation and/// keychain enumeration cross into the older daemon code.enum GuestAPI {- // IcliKit's in-process bridge is synchronous and has not been audited for- // concurrent callers. Keep its operations off NIO loops and in one order.- static let queue = DispatchQueue(label: "vphoned.api.operations", qos: .userInitiated)+ // Each request executes independently. A synchronous system service such+ // as powerd may wait during boot; it must not hold up HID or file requests.+ static let queue = DispatchQueue(label: "vphoned.api.operations", qos: .userInitiated,+ attributes: .concurrent)static let binaryHash: String = {guard let url = Bundle.main.executableURL,let data = try? Data(contentsOf: url, options: .mappedIfSafe) else { return "unknown" }diff --git a/VPhoneDaemon/Daemon/GuestEventPublisher.swift b/VPhoneDaemon/Daemon/GuestEventPublisher.swiftindex 99ba2d1a..8bd23bb2 100644--- a/VPhoneDaemon/Daemon/GuestEventPublisher.swift+++ b/VPhoneDaemon/Daemon/GuestEventPublisher.swift@@ -2,15 +2,16 @@ import Foundationimport IcliKit/// Publishes the state a UI needs without requiring it to poll over HTTP.-/// The synchronous IcliKit calls share the same serial queue as commands.+/// State polling runs separately so a stalled powerd read cannot block commands.final class GuestEventPublisher: @unchecked Sendable {+ private static let queue = DispatchQueue(label: "vphoned.api.state", qos: .utility)private let hub: APIEventHubprivate let timer: DispatchSourceTimerprivate var previous: Data?init(hub: APIEventHub) {self.hub = hub- timer = DispatchSource.makeTimerSource(queue: GuestAPI.queue)+ timer = DispatchSource.makeTimerSource(queue: Self.queue)timer.schedule(deadline: .now(), repeating: .seconds(3))timer.setEventHandler { [weak self] in self?.publishIfChanged() }timer.resume()