Run a virtual iPhone on an Apple Silicon Mac.
Swift
Duo: chase the recreated machine's rotation wedge to a persistent pin
Jacky020a9f16570d
diff --git a/Research/0_binary_patch_comparison.md b/Research/0_binary_patch_comparison.mdindex 2349d214..ec8be107 100644--- a/Research/0_binary_patch_comparison.md+++ b/Research/0_binary_patch_comparison.md@@ -5281,8 +5281,11 @@ The host VM view now derives its input geometry from the active Duo viewport (`a> older guests. This changes admission only for the known Duo model and keeps> the lock-screen wallpaper path unchanged.-> **Poster compositor probe (2026-10-27):** Added a separate read-only-> `libvphoneposterprobe.dylib`. SystemHook loads it only for paths containing-> `PosterBoard`/`poster`; it records bounded JSON for connected scenes, screen-> bounds/scale, private display-mode description, activation state, PID and-> uptime. It performs no swizzling, pixel capture, or scene mutation.+> **Poster compositor follower (2026-10-28):** `libvphoneposterprobe.dylib`+> now coalesces orientation requests for hosted poster renderer processes and+> leaves the PosterBoard wallpaper editor untouched. It reads the settled+> daemon orientation notification before falling back to the map file and+> asks SpringBoard to reconcile newly-created floating poster hosts. The+> SpringBoard-side adapter preserves the editor's portrait bounds and centers+> it inside the landscape presenter, avoiding the repeated-request loading+> loop and the off-center sheet.diff --git a/Research/Guest/iphone_duo_bringup.md b/Research/Guest/iphone_duo_bringup.mdindex ed11535f..ad1518b5 100644--- a/Research/Guest/iphone_duo_bringup.md+++ b/Research/Guest/iphone_duo_bringup.md@@ -4007,3 +4007,52 @@ already routes PosterBoard* processes for the probe). A quick layerbisect anyone can run: set a built-in STILL wallpaper (Settings ›Wallpaper) and rotate — if stills stay upright in every direction, thebug is confined to the extension-rendered photo path.++Follow-up (QuickAction repeat application, 2026-10-28): the long-side walk+was using each glyph's `frame`, which can include the transform already+applied by an earlier rotation or fold pulse. Repeated passes therefore were+not idempotent and could shrink the camera. The walk now reads the+untransformed `bounds`, keeps the flashlight's 16pt long-side target, and+restores the camera to a 0.82 factor; repeated pulses converge to the same+transform. Each glyph now also retains its first native bounds in an+associated value, so a later private layout rewrite cannot feed a transformed+size back into the next pass.+Orientation actuation also schedules three coalesced main-queue passes after+the native CoverSheet layout returns, so a glyph rebuilt late in the rotation+cannot remain at the unscaled native transform.++Follow-up (wallpaper editor loading and floating scene position, 2026-10-28):+the poster probe was issuing a new geometry request every 1.5 seconds while+the PosterBoard editor kept its portrait scene contract. That reset the Add+New Wallpaper loading transition indefinitely. The probe now coalesces+requests, leaves PosterBoard itself alone, and only follows hosted poster+renderer processes. The settled orientation is read from the daemon's Darwin+notification state before falling back to the map file. SpringBoard also keeps+the portrait floating editor scene at its native size and centers it inside+the landscape poster host; renderer containers still fill the native presenter+bounds.++Follow-up (rotation wedge on the recreated machine, 2026-10-28 PM): after+the first 270° request on the recreated duotest-m5, every rotation away+from the inner rest (90°) is refused — the RPC times out with "The Duo+scene did not settle", the pose override verifiably holds the requested+device value during the window (portrait request: pose 3), the+accelerometer sink is healthy, and the forced arbitration still concludes+interface 4 (the mount's mapping of the REST pose device 1, not the+requested device 3). The scene geometry request now fails with+UISceneErrorDomain 101 ("windowing mode does not allow programmatic+changes to interface orientation") — the same public call that delivered+the landscape re-flow on the original machine. Bisection so far: not the+experiment flags (none on disk), not the rotation lock (all keys false,+full lock-cycle does not clear it), not the merged dylib (reverting+libvphonefolddisplay to the pre-merge commit changes nothing), not the+hinge preferences (clean 180°), and not a stale vphoned (pose.refresh now+rides setRotation's sequence too, commit e409fa2b build). The wedge+survives reboots and code reverts, and 0↔90 DID work in the machine's+first minutes before the first 270 request wedged it — pointing at a+persistent guest state or a machine-creation difference (the recreate ran+the current template flow: setUpTemplate/trimTemplate steps the original+never had). Next round: (a) recreate a second machine with trimming+disabled and diff the arbitration behavior, (b) instrument the traits+arbiter's supported-orientation query, (c) compare the scene's+effectiveGeometry on the two machines.diff --git a/VPhoneDaemon/Daemon/GuestAPI+Device.swift b/VPhoneDaemon/Daemon/GuestAPI+Device.swiftindex 2225132c..b4043833 100644--- a/VPhoneDaemon/Daemon/GuestAPI+Device.swift+++ b/VPhoneDaemon/Daemon/GuestAPI+Device.swift@@ -127,9 +127,12 @@ extension GuestAPI {// does not itself enqueue UIKit's orientation// arbitration. Publish the same bounded refresh// sequence used by the native pose pipeline before- // waiting for SpringBoard's scene receipt.+ // waiting for SpringBoard's scene receipt. The+ // pose-refresh channel re-reads the just-set device+ // orientation; inputs.refresh leaves the pipeline on+ // its previous value and the settle times out._ = try? postDarwinNotification("com.vphone.display.orientation.mapping.request", state: nil)- _ = try? postDarwinNotification("com.vphone.display.orientation.inputs.refresh", state: nil)+ _ = try? postDarwinNotification("com.vphone.display.orientation.pose.refresh", state: nil)_ = try? postDarwinNotification("com.vphone.display.orientation.arbitration.refresh", state: nil)_ = try? postDarwinNotification("com.vphone.display.orientation.actuation.refresh", state: nil)_ = try? postDarwinNotification("com.vphone.display.presentation.wallpaper.pulse", state: nil)diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swiftindex f5f7022b..e0f45eb1 100644--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift@@ -66,10 +66,11 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {view.clipboardSync = VPhoneClipboardSync(control: control)virtualMachineView = viewlet scale = CGFloat(screenScale)+ let duoWindowScale = 1 / CGFloat(sqrt(Double(screenScale)))minimumDuoPanelSize = foldableGuest? CGSize(- width: CGFloat(VPhoneGuestDevice.iPhone19_4InnerScreen.width) / scale,- height: CGFloat(VPhoneGuestDevice.iPhone19_4InnerScreen.height) / scale,+ width: CGFloat(VPhoneGuestDevice.iPhone19_4.screen.width) / scale * duoWindowScale,+ height: CGFloat(VPhoneGuestDevice.iPhone19_4.screen.height) / scale * duoWindowScale,): nillet windowSize = homePodGuest ? VPhoneHomePodDisplayView.defaultContentSize : NSSize(@@ -276,9 +277,9 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {private weak var displayContainer: VPhoneDisplayContainerView?private var panelSize: NSSize = .zero- /// The Duo's real inner panel, in window points. The VM keeps enough- /// native pixels for that panel even while the cover is active, so the- /// window must never shrink below it.+ /// The Duo's cover baseline after the host-window reduction. The inner+ /// panel can grow the window when it is active, but must not make the+ /// minimum larger than this compact physical-size baseline.private var minimumDuoPanelSize: CGSize?private var orientationPollInFlight = false@@ -359,7 +360,7 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {container.turn(to: orientation, windowFrame: frame, animated: !force)}- /// Keep a Duo window at least as large as the real inner display. The+ /// Keep a Duo window at least as large as the compact cover baseline. The/// minimum follows the displayed orientation because AppKit's content/// minimum is expressed in the window's current axes.private func setMinimumContentSize(for orientation: VPhoneDisplayOrientation, on window: NSWindow) {diff --git a/VPhoneGuestComponents/FoldDisplay/libvphonefolddisplay.m b/VPhoneGuestComponents/FoldDisplay/libvphonefolddisplay.mindex 692ba665..77333028 100644--- a/VPhoneGuestComponents/FoldDisplay/libvphonefolddisplay.m+++ b/VPhoneGuestComponents/FoldDisplay/libvphonefolddisplay.m@@ -136,12 +136,14 @@ static void vpRestoreInputTrace(void);static void vpExportNativeOrientationMapping(void);static void vpLogicalProjectionControl(NSInteger action);static id vpRootServerScenes(id app);-static NSArray *vpSnapshotRect(id object, const char *name);+static id vpSnapshotRect(id object, const char *name);static void vpProcessViewportWorkspaceRequest(BOOL submit);static void vpApplyRootGeometry(void);static void vpScheduleViewportAdoption(void);static void vpRefreshNativeOrientationActuation(void);static void vpApplyQuickActionGlyphScale(void);+static void vpScheduleQuickActionGlyphScale(void);+static void vpSyncWallpaperSceneHosts(void);// These helpers are kept at the boundary so the extracted status/wallpaper// sections can call them without depending on declaration order. They only@@ -1768,6 +1770,10 @@ static void vpPulseNativeWallpaperOrientation(void) {} @catch (NSException *exception) {vpFoldDisplayLog([NSString stringWithFormat:@"native wallpaper orientation exception: %@", exception.reason]);}+ // PosterBoard may create its floating editor after the wallpaper+ // presenter was rotated. Reconcile the hosted scene after the native+ // wallpaper pass so a portrait editor remains centered in landscape.+ vpSyncWallpaperSceneHosts();// This is now part of the normal Duo orientation pipeline. Do not roll// the wallpaper back after a timer: the scene's current arbitration is// the source of truth and a delayed restore recreates the landscape black@@ -2146,12 +2152,16 @@ static void vpInspectQuickActions(void) {// the only safe lever.// The glyph frames are the symbol metrics times one shared multiplier, so// a tall symbol (flashlight.off.fill, 20x37pt) towers over a wide one-// (camera.fill, 24x18pt) under any uniform factor. The accepted camera-// size is a ~16pt long side (23.57 x 0.68), so each glyph is normalized-// by its own long side: the flashlight lands at ~0.44, the camera keeps-// ~0.68, and any future glyph (focus, camera-on) comes out consistent-// without a per-action table.-static double const vpQuickActionGlyphLongSide = 16.0;+// (camera.fill, 24x18pt) under any uniform factor. Keep the flashlight at+// the accepted 16pt long side, while restoring the camera to the 0.82 target+// factor selected by the real-device comparison. Bounds are deliberately used+// below: unlike frame, they are in the glyph's own coordinate space and do+// not include the transform we set. This makes every retry idempotent during+// rotation/fold pulses and prevents the camera from being scaled down again.+static double const vpQuickActionTallGlyphLongSide = 16.0;+static double const vpQuickActionCameraScale = 0.82;+static char vpQuickActionNativeBoundsKey;+static atomic_uint vpQuickActionScaleGeneration;static void vpApplyQuickActionGlyphScale(void) {@try {@@ -2165,14 +2175,35 @@ static void vpApplyQuickActionGlyphScale(void) {[pending removeLastObject];if ([view isKindOfClass:objc_getClass("CSQuickActionImageGlyphView")]) {SEL transformSelector = sel_registerName("transform");- SEL frameSelector = sel_registerName("frame");- if (![view respondsToSelector:transformSelector] || ![view respondsToSelector:frameSelector]) continue;+ SEL boundsSelector = sel_registerName("bounds");+ if (![view respondsToSelector:transformSelector] || ![view respondsToSelector:boundsSelector]) continue;CGAffineTransform current = ((CGAffineTransform (*)(id, SEL))objc_msgSend)(view, transformSelector);- CGRect frame = ((CGRect (*)(id, SEL))objc_msgSend)(view, frameSelector);+ CGRect bounds = ((CGRect (*)(id, SEL))objc_msgSend)(view, boundsSelector);touched++;- double longSide = fmax(frame.size.width, frame.size.height);+ // UIKit's bounds should be transform-independent, but+ // this private glyph view can be relaid out with a new+ // bounds after a fold. Capture the first native value so+ // later passes cannot turn a prior result into their new+ // input, even if the view's layout code rewrites it.+ NSValue *nativeBoundsValue = objc_getAssociatedObject(view, &vpQuickActionNativeBoundsKey);+ CGRect nativeBounds = bounds;+ if ([nativeBoundsValue isKindOfClass:[NSValue class]]) {+ [nativeBoundsValue getValue:&nativeBounds size:sizeof(nativeBounds)];+ } else {+ // Do not freeze the pre-layout zero rect. The next+ // scheduled pass must be allowed to capture the+ // first real glyph bounds.+ if (fmax(bounds.size.width, bounds.size.height) < 1) continue;+ nativeBoundsValue = [NSValue value:&nativeBounds withObjCType:@encode(CGRect)];+ objc_setAssociatedObject(view, &vpQuickActionNativeBoundsKey,+ nativeBoundsValue, OBJC_ASSOCIATION_RETAIN_NONATOMIC);+ }+ double longSide = fmax(nativeBounds.size.width, nativeBounds.size.height);if (longSide < 1) continue;- double scale = vpQuickActionGlyphLongSide / longSide;+ BOOL isWideGlyph = nativeBounds.size.width > nativeBounds.size.height * 1.15;+ double scale = isWideGlyph+ ? vpQuickActionCameraScale+ : vpQuickActionTallGlyphLongSide / longSide;if (scale > 1) scale = 1;if (scale < 0.2) scale = 0.2;if (fabs(current.a - scale) < 0.001 &&@@ -2186,13 +2217,31 @@ static void vpApplyQuickActionGlyphScale(void) {}}if (rescaled)- vpFoldDisplayLog([NSString stringWithFormat:@"quick action glyph scale: %lu of %lu views normalized to %.0fpt long side",- (unsigned long)rescaled, (unsigned long)touched, vpQuickActionGlyphLongSide]);+ vpFoldDisplayLog([NSString stringWithFormat:@"quick action glyph scale: %lu of %lu views (camera %.2f, tall long side %.0fpt)",+ (unsigned long)rescaled, (unsigned long)touched, vpQuickActionCameraScale,+ vpQuickActionTallGlyphLongSide]);} @catch (NSException *exception) {vpFoldDisplayLog([NSString stringWithFormat:@"quick action glyph scale exception: %@", exception.reason]);}}+// The native orientation callback starts a new CoverSheet layout; its glyph+// views can be rebuilt after the callback returns. Apply on the next main-queue+// turn and at two short settling points, while coalescing stale rotation+// schedules. Each pass is safe because it uses the cached native bounds above.+static void vpScheduleQuickActionGlyphScale(void) {+ if (!vpAutomaticMainStatus) return;+ unsigned int generation = atomic_fetch_add_explicit(&vpQuickActionScaleGeneration, 1, memory_order_acq_rel) + 1;+ const double delays[] = {0.0, 0.12, 0.4};+ for (NSUInteger index = 0; index < sizeof(delays) / sizeof(delays[0]); ++index) {+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delays[index] * NSEC_PER_SEC)),+ dispatch_get_main_queue(), ^{+ if (generation != atomic_load_explicit(&vpQuickActionScaleGeneration, memory_order_acquire)) return;+ vpApplyQuickActionGlyphScale();+ });+ }+}+// Full window inventory with two subview levels: identifies which window or// view owns any on-screen black band in landscape.static void vpInspectAllWindows(void) {@@ -2225,12 +2274,12 @@ static void vpInspectAllWindows(void) {}}-// Experiment: the poster extension's hosted scene presentation views keep-// their portrait 669x951 bounds inside the landscape wallpaper tree. This-// opt-in pulse resizes those scene-host nodes to the wallpaper presenter's-// current bounds and requests layout, mirroring the outer frame-// synchronization already part of the Duo wallpaper pulse. Nothing runs-// without this notification; a later rotation can redo it.+// The poster extension's hosted scene presentation views keep their portrait+// 669x951 bounds inside the landscape wallpaper tree. Renderer host nodes are+// resized to the wallpaper presenter's current bounds; the PosterBoard+// floating editor keeps its native portrait bounds and is centered instead.+// The notification is cheap and idempotent, so a newly-created editor can be+// reconciled without touching its loading state.static NSString *vpSizeText(CGSize size) {return [NSString stringWithFormat:@"{%.0f, %.0f}", size.width, size.height];}@@ -2255,9 +2304,34 @@ static void vpSyncWallpaperSceneHosts(void) {[pending removeLastObject];NSString *className = NSStringFromClass([view class]);CGRect bounds = ((CGRect (*)(id, SEL))objc_msgSend)(view, sel_registerName("bounds"));- if ([className isEqualToString:@"_UIScenePresentationView"] ||- [className isEqualToString:@"_UISceneLayerHostContainerView"] ||- [className isEqualToString:@"_UITouchPassthroughView"]) {+ if ([className isEqualToString:@"_UIScenePresentationView"]) {+ id parent = vpReadObject(view, "superview");+ NSString *parentClass = parent ? NSStringFromClass([parent class]) : @"";+ // The floating poster editor remains portrait-native. Keep+ // its scene bounds intact, but center that scene inside the+ // landscape poster host instead of stretching it (stretching+ // restarts its loading transition and leaves the sheet off+ // the visual center). Wallpaper render hosts still fill the+ // presenter below.+ if ([parentClass containsString:@"PosterFloating"] &&+ bounds.size.width < presenterBounds.size.width &&+ bounds.size.height > presenterBounds.size.height) {+ @try {+ CGRect centered = CGRectMake(+ floor((presenterBounds.size.width - bounds.size.width) / 2.0),+ floor((presenterBounds.size.height - bounds.size.height) / 2.0),+ bounds.size.width, bounds.size.height);+ [view setValue:[NSValue value:¢ered withObjCType:@encode(CGRect)] forKey:@"frame"];+ ((void (*)(id, SEL))objc_msgSend)(view, sel_registerName("setNeedsLayout"));+ synced++;+ vpFoldDisplayLog([NSString stringWithFormat:@"wallpaper scene host center: %@ size=%@ origin={%.0f, %.0f}",+ parentClass, vpSizeText(bounds.size), centered.origin.x, centered.origin.y]);+ } @catch (NSException *exception) {+ vpFoldDisplayLog([NSString stringWithFormat:@"wallpaper scene host center exception: %@", exception.reason]);+ }+ }+ } else if ([className isEqualToString:@"_UISceneLayerHostContainerView"] ||+ [className isEqualToString:@"_UITouchPassthroughView"]) {if (!CGSizeEqualToSize(bounds.size, presenterBounds.size)) {@try {CGRect rect = CGRectMake(0, 0, presenterBounds.size.width, presenterBounds.size.height);@@ -3123,6 +3197,7 @@ static void vpRefreshNativeOrientationActuation(void) {// direction makes the space swap (951x669) and the icon family and// windows re-flow.vpRequestSceneGeometry(scene, direction);+ vpScheduleQuickActionGlyphScale();} @catch (NSException *exception) {vpFoldDisplayLog([NSString stringWithFormat:@"orientation actuation exception: %@", exception.reason]);}@@ -4094,9 +4169,6 @@ static int persistentCoverToken, persistentInnerToken;notify_register_dispatch("com.vphone.display.orientation.actuation.refresh", &actuationRefreshToken, dispatch_get_main_queue(),^(int token) {vpRefreshNativeOrientationActuation();- // Rotation pulses rebuild lock-screen presentation; fresh glyph- // instances render at the native factor until re-scaled.- if (vpAutomaticMainStatus) vpApplyQuickActionGlyphScale();});static int embeddedOrientationToken, embeddedOrientationRestoreToken;notify_register_dispatch("com.vphone.display.orientation.embedded.sync", &embeddedOrientationToken, dispatch_get_main_queue(),