fix: Emit interface orientation when updates start and on didBecomeActive - #4120
Open
robkingtech wants to merge 1 commit into
Open
fix: Emit interface orientation when updates start and on didBecomeActive#4120robkingtech wants to merge 1 commit into
robkingtech wants to merge 1 commit into
Conversation
…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>
|
Someone is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:init()readsUIApplication.shared.interfaceOrientation, which filtersconnectedScenesfor.foregroundActive— but during a cold launch the scene is not yetforegroundActive, so the orientation resolves to.unknown(treated as portrait). This can still be true by the timestartOrientationUpdates()runs, since the camera typically starts very early in the launch sequence.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). ThedidBecomeActiveobserver is cleaned up instopOrientationUpdates().An emit-only-at-
startOrientationUpdatesvariant was not sufficient in our testing — the scene can still be inactive at that point during a cold launch — which is why thedidBecomeActivere-emit is the load-bearing part.Testing
Notes
HybridDeviceOrientationManagermay 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.