Skip to content

Commit 87ff819

Browse files
fix(scripts): make Full Screen Apps mode stick on freshly created simulators
The first CI run captured a floating portrait-screen window: on a brand new device SBChamoisWindowingEnabled alone is not honored. The Settings toggle writes three SpringBoard keys (Chamois windowing, Medusa multitasking, flexible-windowing stage creation), so write all three, reboot the simulator instead of kickstarting SpringBoard, and verify the mode applied. Also gate showcase scene readiness on the orientation having settled, and report orientation from screen bounds so a floating landscape window on a portrait screen counts as portrait — an early or failed rotation now times out loudly instead of shipping wrong-size screenshots. Verified locally against a freshly created simulator (the CI-equivalent path): upright landscape 2752x2064, validation passes. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 6a80bae commit 87ff819

3 files changed

Lines changed: 52 additions & 24 deletions

File tree

‎apps/mobile/modules/t3-native-controls/ios/T3NativeControlsModule.swift‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,20 @@ public final class T3NativeControlsModule: Module {
6161

6262
// The geometry request above can fail transiently (for example before the
6363
// scene is foreground-active), so callers poll this until it settles.
64+
// Screen bounds — not the scene's interface orientation — decide the
65+
// answer because they match the captured framebuffer: with iPadOS
66+
// windowing active, a floating landscape window still reports a portrait
67+
// screen, and screenshots would come out portrait.
6468
AsyncFunction("getInterfaceOrientation") { () -> String in
65-
guard #available(iOS 16.0, *),
69+
guard
6670
let windowScene = UIApplication.shared.connectedScenes
6771
.compactMap({ $0 as? UIWindowScene })
6872
.first
6973
else {
7074
return "unknown"
7175
}
72-
return windowScene.effectiveGeometry.interfaceOrientation.isLandscape
73-
? "landscape"
74-
: "portrait"
76+
let bounds = windowScene.screen.coordinateSpace.bounds
77+
return bounds.width > bounds.height ? "landscape" : "portrait"
7578
}.runOnQueue(.main)
7679

7780
Function("prepareShowcaseCapture") {

‎apps/mobile/src/features/showcase/ShowcaseCaptureCoordinator.tsx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
4949
const [pendingTasksReady, setPendingTasksReady] = useState(false);
5050
const [requestedScene, setRequestedScene] = useState<ShowcaseScene | null>(null);
5151
const [readyScene, setReadyScene] = useState<ShowcaseScene | null>(null);
52+
const [orientationSettled, setOrientationSettled] = useState(false);
5253

5354
useEffect(() => {
5455
if (!SHOWCASE_ENABLED || pairingUrls.length > 0) return;
@@ -63,18 +64,23 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
6364
}, [pairingUrls.length]);
6465

6566
useEffect(() => {
66-
if (!SHOWCASE_ENABLED) return;
67+
if (!SHOWCASE_ENABLED || orientationSettled) return;
6768
const orientation = getNativeShowcaseOrientation();
68-
if (orientation === null) return;
69+
if (orientation === null) {
70+
setOrientationSettled(true);
71+
return;
72+
}
6973

7074
let cancelled = false;
7175
void retryShowcaseOperation(async () => applyNativeShowcaseOrientation(orientation), {
7276
isCancelled: () => cancelled,
77+
}).then((applied) => {
78+
if (!cancelled && applied) setOrientationSettled(true);
7379
});
7480
return () => {
7581
cancelled = true;
7682
};
77-
}, []);
83+
}, [orientationSettled]);
7884

7985
useEffect(() => {
8086
if (!SHOWCASE_ENABLED) return;
@@ -198,7 +204,10 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
198204
scene === null ||
199205
requestedScene === null ||
200206
scene !== requestedScene ||
201-
!hasFixture
207+
!hasFixture ||
208+
// Never report a scene ready while the capture orientation is still
209+
// being applied — a screenshot taken early has the wrong dimensions.
210+
!orientationSettled
202211
) {
203212
setReadyScene(null);
204213
return;
@@ -226,7 +235,7 @@ export function ShowcaseCaptureCoordinator(props: { readonly pathname: string })
226235
if (renderFrame !== null) cancelAnimationFrame(renderFrame);
227236
if (readyFrame !== null) cancelAnimationFrame(readyFrame);
228237
};
229-
}, [hasFixture, requestedScene, scene]);
238+
}, [hasFixture, orientationSettled, requestedScene, scene]);
230239

231240
if (!SHOWCASE_ENABLED || readyScene === null) return null;
232241

‎scripts/mobile-showcase.ts‎

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -810,27 +810,43 @@ async function ensureIosFullScreenAppsMode(udid: string): Promise<void> {
810810
"SBChamoisWindowingEnabled",
811811
]).catch(() => "");
812812
if (current.trim() === "0") return;
813-
await runCommand("xcrun", [
813+
// The Settings toggle writes all three keys; SBChamoisWindowingEnabled
814+
// alone is not honored on a freshly created device.
815+
for (const key of [
816+
"SBChamoisWindowingEnabled",
817+
"SBMedusaMultitaskingEnabled",
818+
"SBFlexibleWindowingPreviouslyEnabledAutomaticStageCreation",
819+
]) {
820+
await runCommand("xcrun", [
821+
"simctl",
822+
"spawn",
823+
udid,
824+
"defaults",
825+
"write",
826+
"com.apple.springboard",
827+
key,
828+
"-bool",
829+
"false",
830+
]);
831+
}
832+
// A SpringBoard restart is not enough on a freshly created simulator (the
833+
// first CI run captured with windowing still active), so reboot the device
834+
// and verify the mode actually stuck.
835+
await runCommand("xcrun", ["simctl", "shutdown", udid]);
836+
await runCommand("xcrun", ["simctl", "boot", udid]);
837+
await runCommand("xcrun", ["simctl", "bootstatus", udid, "-b"]);
838+
const applied = await commandOutput("xcrun", [
814839
"simctl",
815840
"spawn",
816841
udid,
817842
"defaults",
818-
"write",
843+
"read",
819844
"com.apple.springboard",
820845
"SBChamoisWindowingEnabled",
821-
"-bool",
822-
"false",
823-
]);
824-
await runCommand("xcrun", [
825-
"simctl",
826-
"spawn",
827-
udid,
828-
"launchctl",
829-
"kickstart",
830-
"-k",
831-
"user/foreground/com.apple.SpringBoard",
832-
]);
833-
await delay(5_000);
846+
]).catch(() => "");
847+
if (applied.trim() !== "0") {
848+
throw new Error(`Simulator ${udid} did not switch to Full Screen Apps mode.`);
849+
}
834850
}
835851

836852
async function iosAppContainer(udid: string): Promise<string> {

0 commit comments

Comments
 (0)