Skip to content

fix: Emit interface orientation when updates start and on didBecomeActive - #4120

Open
robkingtech wants to merge 1 commit into
margelo:mainfrom
robkingtech:fix/interface-orientation-cold-launch
Open

fix: Emit interface orientation when updates start and on didBecomeActive#4120
robkingtech wants to merge 1 commit into
margelo:mainfrom
robkingtech:fix/interface-orientation-cold-launch

Conversation

@robkingtech

Copy link
Copy Markdown

What

Fixes the camera preview (and all outputs) rendering 90° rotated when an app is cold-launched while the device is held in landscape — easiest to reproduce on iPad, where landscape launches are normal. Physically rotating the device once corrects it, and it stays correct for the rest of the session. Both orientationSource="interface" and "device" reproduce it.

Root cause

Two things combine in HybridInterfaceOrientationManager:

  1. init() reads UIApplication.shared.interfaceOrientation, which filters connectedScenes for .foregroundActive — but during a cold launch the scene is not yet foregroundActive, so the orientation resolves to .unknown (treated as portrait). This can still be true by the time startOrientationUpdates() runs, since the camera typically starts very early in the launch sequence.
  2. After that, updates only come from UIDevice.orientationDidChangeNotification — which never fires until the device is physically rotated, so the wrong initial value is never corrected.

Fix

Emit the current interface orientation when orientation updates start (covers warm starts), and re-emit on UIApplication.didBecomeActiveNotification — the moment the scene state is guaranteed correct (covers cold launches). The didBecomeActive observer is cleaned up in stopOrientationUpdates().

An emit-only-at-startOrientationUpdates variant was not sufficient in our testing — the scene can still be inactive at that point during a cold launch — which is why the didBecomeActive re-emit is the load-bearing part.

Testing

  • Reproduced on iPad mini (6th generation), iPadOS 26, VisionCamera 5.2.0: cold launch in landscape → preview rotated 90°; rotate once → corrects.
  • With this fix (applied via patch-package to 5.2.0 and rebuilt): cold landscape launch renders correctly from the first frame; rotation behaviour afterwards unchanged; portrait launches unchanged. Verified through TestFlight on physical hardware.

Notes

HybridDeviceOrientationManager may benefit from a similar guard for its initial reading, but this PR intentionally only touches the interface manager, which is the path we could verify on hardware.

…tive

On a cold launch the window scene is not yet foregroundActive when
HybridInterfaceOrientationManager reads the interface orientation -
during init() and potentially still when startOrientationUpdates() runs
- so it resolves to .unknown (treated as portrait). The manager then
only updates on UIDevice.orientationDidChangeNotification, which never
fires until the device is physically rotated.

Result: an app cold-launched in landscape (common on iPad) renders the
preview and all outputs rotated 90 degrees until the user rotates the
device once. Reproducible with both orientationSource values.

Fix: emit the current interface orientation when orientation updates
start, and again on UIApplication.didBecomeActiveNotification - the
moment the scene state is guaranteed correct. Verified on iPad mini
(6th gen), iPadOS 26: cold landscape launch now renders correctly from
the first frame.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant