Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Duo: record the wallpaper path-dependence and the layer bisect

Jacky5983646b0ee1
diff --git a/Research/Guest/iphone_duo_bringup.md b/Research/Guest/iphone_duo_bringup.md
index 3cecd311..ed11535f 100644
--- a/Research/Guest/iphone_duo_bringup.md
+++ b/Research/Guest/iphone_duo_bringup.md
@@ -3990,3 +3990,20 @@ current dylib directly (marker verified in-guest), the wallpaper
orientation bridge installs, and 3× fold cycles land closed 466×678/0°
and open 669×951/90°. Wallpaper orientation judgment needs the user's
directional wallpaper set again on the fresh machine.
+
+Follow-up (wallpaper flakiness, honest status): on the fresh machine the
+landscape wallpaper is path-dependent — sometimes a correct full-bleed
+frame, sometimes a portrait-width strip with a gray-black remainder,
+with the display stream even observed frozen across three rapid
+rotations (byte-identical captures). The pulse (frame sizing) +
+orientation bridge (device→interface through the mounting table) +
+device-code mirror are all armed together now; each individually helps
+one path but no combination is stable across sequences. Remaining
+suspicion: photo wallpapers render through the poster-extension
+processes (PhotosPosterProv and siblings), whose hosted-scene rotation
+our SpringBoard-side hooks never touch — the next engineering round is
+injecting an orientation follower into those extensions (SystemHook
+already routes PosterBoard* processes for the probe). A quick layer
+bisect anyone can run: set a built-in STILL wallpaper (Settings ›
+Wallpaper) and rotate — if stills stay upright in every direction, the
+bug is confined to the extension-rendered photo path.
diff --git a/VPhoneDaemon/Daemon/GuestAPI+Device.swift b/VPhoneDaemon/Daemon/GuestAPI+Device.swift
index e32b0a1e..45e6f145 100644
--- a/VPhoneDaemon/Daemon/GuestAPI+Device.swift
+++ b/VPhoneDaemon/Daemon/GuestAPI+Device.swift
@@ -132,6 +132,7 @@ extension GuestAPI {
_ = try? postDarwinNotification("com.vphone.display.orientation.inputs.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)
_ = try? postDarwinNotification("com.vphone.display.presentation.clock.refresh", state: nil)
}
var result: [String: Any]
@@ -509,6 +510,7 @@ extension GuestAPI {
_ = 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)
_ = try? postDarwinNotification("com.vphone.display.presentation.clock.refresh", state: nil)
if !settled {
// Reuse the same public rotation path once the new panel
diff --git a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift
index d86bb1b6..f5f7022b 100644
--- a/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift
+++ b/VPhoneExecutable/VPhoneVirtualization/UI/UserInterface/VPhoneVirtualMachineWindowController.swift
@@ -66,6 +66,12 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {
view.clipboardSync = VPhoneClipboardSync(control: control)
virtualMachineView = view
let scale = CGFloat(screenScale)
+ minimumDuoPanelSize = foldableGuest
+ ? CGSize(
+ width: CGFloat(VPhoneGuestDevice.iPhone19_4InnerScreen.width) / scale,
+ height: CGFloat(VPhoneGuestDevice.iPhone19_4InnerScreen.height) / scale,
+ )
+ : nil
let windowSize = homePodGuest ? VPhoneHomePodDisplayView.defaultContentSize : NSSize(
width: CGFloat(screenWidth) / scale,
height: CGFloat(screenHeight) / scale,
@@ -112,6 +118,7 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {
window.level = .normal
VPhoneAlert.hostWindow = window
window.contentAspectRatio = windowSize
+ setMinimumContentSize(for: .portrait, on: window)
window.title = name
window.contentView = container
@@ -124,6 +131,7 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {
window.center()
}
window.setFrameAutosaveName(sceneName)
+ setMinimumContentSize(for: .portrait, on: window)
observeKeyState(of: window)
// A frame saved while the guest was sideways is turned back: the guest
// boots in portrait, and the orientation poll turns it again if not.
@@ -268,6 +276,10 @@ 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.
+ private var minimumDuoPanelSize: CGSize?
private var orientationPollInFlight = false
/// Asks vphoned for the interface orientation once a second. Guests
@@ -333,6 +345,7 @@ class VPhoneVirtualMachineWindowController: NSObject, NSWindowDelegate {
/// full-screen one keeps the screen and letterboxes the turned panel.
private func applyOrientation(_ orientation: VPhoneDisplayOrientation, to window: NSWindow, force: Bool = false) {
guard let container = displayContainer, force || container.orientation != orientation else { return }
+ setMinimumContentSize(for: orientation, on: window)
window.contentAspectRatio = orientation.displayedSize(panel: panelSize)
var frame: NSRect?
if !window.styleMask.contains(.fullScreen) {
@@ -346,6 +359,25 @@ 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
+ /// 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) {
+ guard let minimumDuoPanelSize else { return }
+ let minimum = orientation.displayedSize(panel: minimumDuoPanelSize)
+ window.contentMinSize = minimum
+
+ let current = window.contentRect(forFrameRect: window.frame)
+ let target = CGSize(width: max(current.width, minimum.width), height: max(current.height, minimum.height))
+ guard target != current.size else { return }
+ let center = NSPoint(x: window.frame.midX, y: window.frame.midY)
+ window.setContentSize(target)
+ window.setFrameOrigin(NSPoint(
+ x: center.x - window.frame.width / 2,
+ y: center.y - window.frame.height / 2,
+ ))
+ }
+
// MARK: - Mac Shortcuts
/// The Mac's own shortcuts on keys the guest uses are off while this window