Skip to content

Update iOS orientation handling to use UIDevice.CurrentDevice - #39398

Merged
kubaflo merged 3 commits into
dotnet:inflight/currentfrom
jgold6:patch-1
Oct 20, 2026
Merged

kubaflo merged 3 commits into
dotnet:inflight/currentfrom
jgold6:patch-1

Conversation

@jgold6

@jgold6 jgold6 commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Replaced deprecated status bar orientation notifications with UIDevice orientation notifications for iOS.

Description of Change

Switches using the deprecated
UIApplication.DidChangeStatusBarOrientationNotification
and
UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()
to use
UIDevice.OrientationDidChangeNotification
and
UIDevice.CurrentDevice.Orientation.IsLandscape();
instead

Issues Fixed

Fixes #39182
#39182

Replaced deprecated status bar orientation notifications with UIDevice orientation notifications for iOS.
@jgold6
jgold6 temporarily deployed to copilot-pat-pool October 15, 2026 10:00 — with GitHub Actions Inactive
@jgold6
jgold6 temporarily deployed to copilot-pat-pool October 15, 2026 10:00 — with GitHub Actions Inactive
@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Oct 15, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @@jgold6! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hey there @jgold6! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 39398

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 39398"

@jgold6
jgold6 temporarily deployed to copilot-pat-pool October 15, 2026 10:01 — with GitHub Actions Inactive
@jgold6
jgold6 temporarily deployed to copilot-pat-pool October 15, 2026 10:03 — with GitHub Actions Inactive
@jgold6
jgold6 temporarily deployed to copilot-pat-pool October 15, 2026 10:05 — with GitHub Actions Inactive
@jgold6
jgold6 temporarily deployed to copilot-pat-pool October 15, 2026 10:05 — with GitHub Actions Inactive
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 15, 2026
@kubaflo

This comment has been minimized.

@kubaflo

kubaflo commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

UIInterfaceOrientation.LandscapeRight => DisplayRotation.Rotation90,
UIDeviceOrientation.Portrait => DisplayRotation.Rotation0,
UIDeviceOrientation.PortraitUpsideDown => DisplayRotation.Rotation180,
UIDeviceOrientation.LandscapeLeft => DisplayRotation.Rotation270,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[major] Logic and Correctness Verification - The landscape mapping cannot be copied unchanged from UIInterfaceOrientation to UIDeviceOrientation because their LandscapeLeft and LandscapeRight meanings are reversed. With autorotation enabled, UIDeviceOrientation.LandscapeLeft corresponds to UIInterfaceOrientation.LandscapeRight, which previously returned Rotation90; this branch now returns Rotation270 for the same displayed orientation. The opposite landscape position is reversed too, activating the wrong DisplayRotationStateTrigger. Preserve the existing display rotation convention; if retaining device orientation as the input, swap the landscape mappings and cover both positions.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I installed this fix as a PR build version and tested it on a iPhone DUO simulator and I think it is not yet the way it should be:

If i turn the device on a closed duo phone it looks oke. When the phone is in portrait mode and then open the phone it should go to landscape mode, but it stays in portrait mode. Because the start state is not correct al the other states are also not correct. I tested just on a simulator.

Please reopen this issue.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 2 findings

Reviewed commit 4ed5ca7.

Previously reported findings were not duplicated.

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 2 findings

See inline comments for details.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

@jgold6 — new AI review results are available based on commit 4ed5ca7.

Gate No Tests Confidence Low Platform iOS


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ⚠️ SKIPPED

No tests were detected in this PR.

Recommendation: Add tests to verify the fix using the write-tests-agent.


📋 Pre-Flight — Context & Validation

Pre-Flight Context

Scope: Evidence-only context for #39398, based on immutable base 5375f6f87279945656cd5d15ec094f16dd8d9aff, submitted head 4ed5ca736966bccf2909807150a4f5709262dd6c, linked issue #39182, and relevant repository source. This is not an exhaustive review or correctness verdict.

Reported problem

  • #39182 reports that on iOS 27, DeviceDisplay.Current.MainDisplayInfo.Orientation remains Portrait and MainDisplayInfoChanged does not fire after rotation.
  • A later issue comment also reports MainDisplayInfo.Rotation remaining Rotation0.
  • The report names .NET MAUI 10.0.110, the latest .NET 10 iOS SDK, and Xcode 27.
  • Maintainer validation reproduced the behavior with MAUI 10.0.0 and 10.0.110 on iOS 27, while reporting that iOS 26.5 still worked.
  • The last known working MAUI version and precise regression boundary remain unknown.
  • The original report had no public reproduction link. A later comment attached Issue39182.zip; its contents were not inspected and are therefore unknown.

Submitted change and mechanism

The PR changes one file, src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs (8 additions and 8 deletions):

  • Replaces UIApplication.DidChangeStatusBarOrientationNotification with UIDevice.OrientationDidChangeNotification.
  • Replaces UIApplication.SharedApplication.StatusBarOrientation with UIDevice.CurrentDevice.Orientation.
  • Maps UIDeviceOrientation.Portrait, PortraitUpsideDown, LandscapeLeft, and LandscapeRight to the existing DisplayRotation values.
  • Derives DisplayOrientation from UIDeviceOrientation.IsLandscape().

Relevant surrounding behavior:

  • GetFallbackDisplayInfo() combines UIScreen bounds, scale, and refresh rate with CalculateOrientation() and CalculateRotation().
  • The shared DeviceDisplayImplementationBase starts platform listeners when the first MainDisplayInfoChanged subscriber is added and stops them when the last subscriber is removed.
  • A notification only reaches subscribers when the newly calculated complete DisplayInfo differs from the cached value.
  • No public API surface is changed.

Platform-sensitive paths

  • The requested validation platform is iOS; the reported version boundary is specifically iOS 27 versus iOS 26.5.
  • .ios.cs also compiles for Mac Catalyst. Its normal Mac Catalyst path and screen-parameter notification remain unchanged, but the modified orientation helpers are outside the MACCATALYST conditional and can be reached by the Mac Catalyst fallback path when Core Graphics display-mode acquisition fails.
  • Repository prior art in AlertManager.iOS.cs and compatibility Platform.cs calls BeginGeneratingDeviceOrientationNotifications() before observing UIDevice.OrientationDidChangeNotification, then calls EndGeneratingDeviceOrientationNotifications() during cleanup. The submitted implementation only adds and disposes the observer. Whether explicit generation is required for this DeviceDisplay lifecycle on iOS 27 remains unverified.
  • UIDeviceOrientation describes physical-device orientation and may report Unknown, FaceUp, or FaceDown. The submitted orientation calculation classifies every non-landscape value as Portrait, while rotation returns Unknown for those states.
  • Physical-device orientation can differ from interface orientation under orientation locks, transient rotations, multitasking, or windowing. The intended DeviceDisplay semantics in those cases need confirmation.
  • Landscape-left/right rotation conventions need direct validation after changing enum domains.
  • The method still carries an UnsupportedOSPlatform("ios13.0") annotation and analyzer suppressions whose comments refer to the removed UIApplication.StatusBarOrientation APIs; their continued necessity is undetermined.

Validation requirements

The supplied Gate result is ⚠️ SKIPPED — no tests detected in this PR. The submitted diff contains no test changes. Existing DeviceDisplay device coverage located in the repository checks positive width, height, and density but does not exercise orientation changes or MainDisplayInfoChanged; existing unit coverage exercises shared event plumbing rather than UIKit behavior.

Later validation should therefore establish on iOS:

  • Correct initial Orientation and Rotation.
  • Correct event delivery and event payload after portrait, upside-down, landscape-left, and landscape-right transitions.
  • Behavior for transient Unknown, FaceUp, and FaceDown values.
  • Correct subscribe, unsubscribe, multiple-subscriber, and re-subscribe lifecycle behavior, including any required BeginGenerating…/EndGenerating… symmetry.
  • Behavior with application orientation locks and applicable iPad multitasking/window configurations.
  • Reproduction resolution on iOS 27 and regression safety on an earlier supported iOS version, including the reported iOS 26.5 comparison.
  • iOS and Mac Catalyst compilation, including platform-availability diagnostics from the now-stale annotation/suppression region.
  • Change-specific automated device coverage where the infrastructure can reliably drive or simulate orientation transitions.

Remaining uncertainties

  • No submitted-head runtime result on iOS 27 was available.
  • PR discussion records pipelines being started, but their completion and results are unknown.
  • Whether another framework component already enables device-orientation generation globally at runtime is unknown.
  • Behavior on physical hardware versus simulator is unknown.
  • Mac Catalyst fallback behavior after the helper change is unknown.
  • No completed review was present in the retrieved PR review data.
  • The reason for GitHub’s reported blocked mergeability was not established.

🔬 Code Review — Deep Analysis

Code Review — PR #39398

Independent Assessment

What this changes: The iOS DeviceDisplay implementation replaces deprecated status-bar orientation observation and reads with UIDevice orientation notification and state APIs.
Inferred motivation: Restore display-orientation updates on iOS 27, where the removed status-bar APIs no longer provide working change notifications.

Reconciliation with PR Narrative

Author claims: The PR replaces deprecated UIApplication status-bar orientation notification/state APIs with UIDevice equivalents to fix #39182.
Agreement/disagreement: The submitted diff makes that replacement, but it omits the generation lifecycle required by the selected UIDevice notification and does not preserve correct semantics for non-cardinal device states.

Prior Review Reconciliation

No prior ❌ Error findings were present in the trusted pre-flight evidence.

Blast Radius Assessment

  • Runs for all instances: The changed helpers affect every iOS fallback display-info read; the observer lifecycle runs whenever the first MainDisplayInfoChanged subscriber is added.
  • Startup impact: No direct app-startup path; the initial MainDisplayInfo read can nevertheless observe a transient UIDeviceOrientation.
  • Static/shared state: UIDevice.CurrentDevice notification generation is process-shared and therefore requires balanced begin/end calls.
  • Mac Catalyst: The observer replacement is excluded by #if MACCATALYST, but the changed calculation helpers remain reachable from its Core Graphics fallback path.

CI Status

  • Required-check result: Undetermined from the supplied evidence.
  • Trusted Gate: ⚠️ SKIPPED — no tests detected in the PR.
  • Classification: No submitted-head runtime evidence for iOS 27 or regression evidence for an earlier supported iOS version.
  • Action taken: Confidence capped at low; Gate was not rerun.

Findings

❌ Error — Device-orientation notification generation is never started

src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs:167 registers UIDevice.OrientationDidChangeNotification, but StartScreenMetricsListeners() never calls UIDevice.CurrentDevice.BeginGeneratingDeviceOrientationNotifications(), and StopScreenMetricsListeners() has no matching EndGeneratingDeviceOrientationNotifications(). Repository iOS consumers in AlertManager.iOS.cs and compatibility Platform.cs explicitly balance those calls around the same notification. A first subscriber can therefore install an observer without causing this component to generate the events needed to fix #39182.

❌ Error — Non-cardinal device states are reported as portrait

src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs:184 uses IsLandscape() ? Landscape : Portrait. UIDeviceOrientation.Unknown, FaceUp, and FaceDown are all non-landscape, so they become DisplayOrientation.Portrait, while the adjacent rotation switch returns DisplayRotation.Unknown for those same values. A transient face-up/unknown state can consequently emit an internally inconsistent display payload and a false portrait transition.

Failure-Mode Probing

  • First subscribe, rotate, unsubscribe, and resubscribe: the observer is disposed and recreated, but generation is neither started nor balanced; event delivery is not established by this implementation.
  • UIDeviceOrientation.FaceUp, FaceDown, or Unknown: orientation becomes Portrait while rotation becomes Unknown, potentially changing the cached DisplayInfo and raising a false event.
  • Multiple subscribers: shared base logic starts the platform listener only for the first subscriber and stops it after the last, so balanced generation calls belong in those existing start/stop methods and should occur once per listener lifetime.
  • Mac Catalyst fallback: non-cardinal UIDeviceOrientation values can reach the changed helpers if Core Graphics mode acquisition fails, so the fallback must not fabricate portrait.

External Output Contract

Not applicable.

Verdict: NEEDS_CHANGES

Confidence: low
Summary: The API replacement targets the reported failure but leaves notification delivery unestablished and introduces incorrect orientation values for ordinary transient UIDevice states. Both are concrete behavioral defects, and the PR has no relevant validation evidence.


🛠️ Try-Fix — Analysis & Comparison

Alternative generation: not requested

Evidence-first mode intentionally omits routine Try-Fix attempts. This is not a failed
attempt, a completed alternative search, or evidence that alternatives have no value.
The expert review may still produce one evidence-backed PR refinement.


📝 PR Finalize — Recommended Title & Description

Assessment: ✏️ Recommend updating — the current metadata is accurate but the title omits the DeviceDisplay component and the description does not fully state how orientation and rotation are now derived.

Recommended title

[iOS] DeviceDisplay: Use UIDevice orientation notifications

Recommended description

Replaces deprecated status bar orientation APIs with `UIDevice` orientation APIs in the iOS `DeviceDisplay` implementation.

### Description of Change

Replaces:

- `UIApplication.DidChangeStatusBarOrientationNotification`
- `UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()`

with:

- `UIDevice.OrientationDidChangeNotification`
- `UIDevice.CurrentDevice.Orientation.IsLandscape()`

`GetFallbackDisplayInfo()` now maps `UIDevice.CurrentDevice.Orientation` to the existing `DisplayOrientation` and `DisplayRotation` values.

### Issues Fixed

Fixes #39182
https://github.com/dotnet/maui/issues/39182

🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Trusted evidence-first context consumed
Code Review NEEDS_CHANGES (low confidence) 2 blocking errors
Gate ⚠️ SKIPPED No tests detected in the submitted PR
Try-Fix not requested Intentional evidence-first omission
Refinement ⚠️ BLOCKED Implemented once; single validation pass was not accepted
Report ✅ COMPLETE

Code Review and Candidate Comparison

Rank Candidate Expert findings Validation Assessment
1 pr-plus-reviewer Addresses both blocking findings and adds mapping regression coverage BLOCKED: candidate-local workload setup failed and the runner rejected its fresh-result contract; diagnostic XHarness output showed 8 passed and 0 failed Strongest real candidate, but not demonstrated merge-ready
2 pr Leaves notification generation unbalanced and maps non-cardinal states to portrait Gate skipped; no submitted-head iOS runtime evidence Submitted fix requires changes

No try-fix-N candidates exist. Routine alternative generation was intentionally not requested.

Summary

The submitted PR selects the relevant modern iOS API, but the raw fix does not start device-orientation notification generation and can report an incorrect portrait orientation for Unknown, FaceUp, and FaceDown. Those blocking findings independently veto approval. The implemented pr-plus-reviewer refinement is the winner because it corrects both mechanisms and adds focused mapping coverage, but it is unsubmitted and its single validation pass remained blocked; therefore the PR must not be described as merge-ready.

Root Cause

iOS 27 no longer delivers the expected behavior through the deprecated status-bar orientation APIs. Replacing them with UIDevice requires both the native notification-generation lifecycle and explicit handling of the broader UIDeviceOrientation state space; the submitted change performs the API substitution without those requirements.

Fix Quality

The raw PR is incomplete and unvalidated. The refinement uses the existing first-listener/last-listener lifecycle for balanced native calls, derives orientation and rotation from one captured value, maps transient states consistently to Unknown, and adds targeted regression coverage. However, candidate setup failed with an unrecognized maui workload and the runner rejected result fidelity despite 8/8 diagnostic XHarness output. iOS 27 rotation behavior, notification delivery, orientation-lock behavior, and Mac Catalyst fallback behavior remain missing evidence.


📱 UI Tests — Button,Label,Layout

Detected UI test categories: Button,Label,Layout

✅ Deep UI tests — 415 passed, 0 failed, 8 skipped across 3 categories on platform-pool agent (replaces in-process counts above).

🧪 UI Test Execution Results (deep, platform pool)

Category Tests Snapshot diffs
Button 105/106 (1 skipped) ✓ —
Label 113/115 (2 skipped) ✓ —
Layout 197/202 (5 skipped) ✓ —
📎 Download drop-deep-uitests artifact (TRX + snapshot diffs)

🧭 Next Steps — reviewer changes required

The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.

Why: The implemented refinement is the strongest real candidate because it resolves both source-backed expert findings and adds focused mapping coverage. It is not demonstrated merge-ready because the single candidate validation pass was blocked, so the submitted PR requires these changes and validated iOS evidence.

Address the actionable findings in this review before merging.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 17, 2026
@MauiBot

MauiBot commented Oct 17, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@jgold6 — existing-test verification for commit 1d14f0d4.

Result SKIPPED Platform Android Commit 1d14f0d4


🧪 Gate analysis — click to expand

⚠ Skipped. No runnable PR tests were selected. The fix has not been verified by this gate.

No interpretable test-group summary was produced. No additional test execution is inferred.

PR head: 1d14f0d4.

Without-fix baseline: 3a7d7287.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Oct 17, 2026
@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@kubaflo

This comment has been minimized.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

/review gate was not started: another review or Gate is already running for this PR.

This command is not queued. Submit it again after the current run finishes.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@jgold6 — test-failure analysis for commit 1d14f0d.

Scope CI failures Commit 1d14f0d


🧪 CI Analysis — click to expand
📊 maui-pr

No failures found.


🧪 maui-pr-devicetests
  • 🟡 Needs human investigation — Android CoreCLR Items Do Not Leak: retained references; no equivalent diagnostic in five bounded main samples.
  • 🟡 Needs human investigation — Same Android work item: crash-signal evidence and incomplete execution also explain the PowerShell/Helix failure, not compilation.

🧪 maui-pr-uitests

🧭 Follow-up — actions and refresh

Next action: Inspect Android crash/retained references and UI hangs; restore complete result collection before refreshing.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo changed the base branch from main to inflight/current October 20, 2026 22:55
@kubaflo
kubaflo merged commit 0561bc9 into dotnet:inflight/current Oct 20, 2026
191 of 201 checks passed
kubaflo pushed a commit that referenced this pull request Oct 21, 2026
Replaced deprecated status bar orientation notifications with UIDevice
orientation notifications for iOS.

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Switches using the deprecated 
UIApplication.DidChangeStatusBarOrientationNotification 
and 
UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()
to use
UIDevice.OrientationDidChangeNotification
and
UIDevice.CurrentDevice.Orientation.IsLandscape();
instead

### Issues Fixed

Fixes #39182
#39182
kubaflo pushed a commit that referenced this pull request Oct 25, 2026
Replaced deprecated status bar orientation notifications with UIDevice
orientation notifications for iOS.

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Switches using the deprecated 
UIApplication.DidChangeStatusBarOrientationNotification 
and 
UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()
to use
UIDevice.OrientationDidChangeNotification
and
UIDevice.CurrentDevice.Orientation.IsLandscape();
instead

### Issues Fixed

Fixes #39182
#39182
kubaflo pushed a commit that referenced this pull request Oct 26, 2026
Replaced deprecated status bar orientation notifications with UIDevice
orientation notifications for iOS.

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Switches using the deprecated 
UIApplication.DidChangeStatusBarOrientationNotification 
and 
UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()
to use
UIDevice.OrientationDidChangeNotification
and
UIDevice.CurrentDevice.Orientation.IsLandscape();
instead

### Issues Fixed

Fixes #39182
#39182
github-actions Bot pushed a commit that referenced this pull request Oct 28, 2026
Replaced deprecated status bar orientation notifications with UIDevice
orientation notifications for iOS.

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Switches using the deprecated 
UIApplication.DidChangeStatusBarOrientationNotification 
and 
UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()
to use
UIDevice.OrientationDidChangeNotification
and
UIDevice.CurrentDevice.Orientation.IsLandscape();
instead

### Issues Fixed

Fixes #39182
#39182
kubaflo pushed a commit that referenced this pull request Nov 4, 2026
…10) (#39879)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

<!-- Enter description of the fix in this section -->

.NET 10 servicing port targeting `release/10.0.1xx-sr13`, following up
on #39398 and replacing #39870. Related alternative: #39403.

Observe the selected window scene's effective geometry and reselect it
as windows and scene lifecycle state change. Read metrics from that
scene's screen so display dimensions, density and refresh rate follow
Duo display handoffs, including geometry changes without physical device
rotation. Orient dimensions using the scene's interface orientation when
screen bounds lag during a handoff.

On iOS 27+, detect scene-backed versus legacy operation at runtime,
retaining orientation notifications when no usable scene is available.
Preserve the older-iOS notification fallback and account for
interface-oriented screen bounds. Mac Catalyst behavior is unchanged. No
public API is added.

#### Validation

The commands below used the installed .NET 11 RC SDK against the .NET 10
targets, with `REPO_ROOT` set to the absolute path of the .NET 10
checkout:

- **Passed:** 20 focused unit tests:
  ```sh
cd /tmp && dotnet test
"$REPO_ROOT/src/Essentials/test/UnitTests/Essentials.UnitTests.csproj"
-c Debug -f net10.0 -p:_MauiDotNetTfm=net10.0 --no-restore --filter
'FullyQualifiedName~Tests.DeviceDisplay_Tests' --verbosity quiet
  ```
- **Passed:** production Essentials iOS build with 0 warnings and 0
errors:
  ```sh
dotnet build "$REPO_ROOT/src/Essentials/src/Essentials.csproj" -c Debug
-f net10.0-ios26.0 -p:_MauiDotNetTfm=net10.0 --no-restore --verbosity
quiet
  ```
- **Simulator runtime, .NET 10 port:** a session-only MAUI app linked to
the exact port-built Essentials assembly. The same scene geometry
request changed the display from `1398 × 2034` portrait to `2034 × 1398`
landscape without an additional physical-orientation notification. With
the parent commit's DeviceDisplay sources there was no
`MainDisplayInfoChanged` event; with this fix there was one event with
the correct dimensions and rotation.
- **Duo handoffs, .NET 10 port:** with the scene held in the same
landscape orientation, opening the simulated Duo left the parent-commit
app reporting the cover-screen `2034 × 1398` dimensions and no event.
The fixed app emitted a new event reporting the inner-screen `2853 ×
2007` dimensions, then another event returning to `2034 × 1398` on
refolding; no additional physical-orientation notification occurred.
Closed, open and partially open poses were exercised.
- **No-manifest app:** the fixed assembly raised a correctly oriented
event on both a current-runtime compatibility scene and an older iOS
simulator. Opening and refolding the current-runtime compatibility app
left its letterboxed virtual display unchanged, so no additional display
event was expected or observed.
- **Runtime caveat:** the .NET 10 probe used
`ValidateXcodeVersion=false` with the installed Xcode 27 and .NET 10 iOS
SDK, an unsupported toolchain combination. Its no-manifest variant also
used a simulator-only iOS 26.5 linker SDK setting. Nine warnings came
from the probe's diagnostic instrumentation, not the production
Essentials build.
- **Coverage limits:** physical hardware was not tested, and the
committed device tests do not automate a real cross-screen handoff.
- **Not validated locally:** device-test host compilation requires
repository build tasks. Building `Microsoft.Maui.BuildTasks.slnf` failed
while archiving MauiPlatformInterop under the installed Xcode
(`xcodebuild` exit code 65); device tests were not run locally on this
branch. The device-test CI pipeline has been requested.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #39182

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 4, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

<!--
!!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING
MAIN. !!!!!!!
-->

### Description of Change

Follow-up to #39398 for the remaining orientation and display-change
failures reported in #39182, including [opening the Duo simulator
without rotating
it](#39182 (comment)).

Physical device-orientation notifications are not sufficient: the
interface geometry can change without another notification, and a scene
can move to a different display while `UIScreen.MainScreen` still
identifies the cover display. Reading scene orientation only inside the
same physical-orientation callback, as proposed in the closed
alternative #39403, also misses that handoff.

On iOS 27 and later, this change:

- Observes the selected `UIWindowScene`'s `effectiveGeometry` and reads
orientation, rotation, density, refresh rate, and dimensions from that
scene's screen.
- Uses interface-oriented fixed-coordinate bounds so the first event is
correct even when `UIScreen.Bounds` has not caught up with a rotation or
display handoff.
- Rebinds when windows and scenes become available, activate,
background, or disconnect. Queued callbacks from an old listener are
invalidated, and observers are removed when the last subscriber leaves.
- Uses actual runtime scene availability rather than the presence of a
scene manifest. If no usable scene exists, it uses the legacy
screen/orientation path with balanced device-notification generation.
Custom window-state-manager selection remains authoritative.

The older-iOS path also observes status-bar orientation changes and
corrects first-event bounds using interface orientation, without
replacing its existing physical-orientation semantics. Mac Catalyst
keeps its separate Core Graphics implementation. No public API changes
or app-side warning suppressions are required.

Adds geometry, lifecycle, scene-selection, fallback, bounds, and
null-subscription regressions. The Essentials iOS device-test host now
uses scenes; its headless scene delegate is shared with the existing Mac
Catalyst host.

#### Validation

Using the locally installed .NET SDK and Xcode:

| Command | Result |
|---|---|
| `dotnet test src/Essentials/test/UnitTests/Essentials.UnitTests.csproj
-c Debug -f net11.0 --no-restore --filter
'FullyQualifiedName~Tests.DeviceDisplay_Tests' -v:q` | 20 passed |
| `dotnet build src/Essentials/src/Essentials.csproj -c Debug -f
net11.0-ios27.0 --no-restore -t:Rebuild -v:q` | Passed; 0 warnings, 0
errors |
| `dotnet build src/Essentials/src/Essentials.csproj -c Debug -f
net11.0-maccatalyst27.0 --no-restore -t:Rebuild -v:q` | Passed; 0
warnings, 0 errors |

Both production builds used the normal analyzers and warnings-as-errors
policy.

Additional local XHarness runs: full iOS Essentials suite **299 passed,
2 skipped**; focused current-iOS suite **17 passed, 1 skipped**; genuine
no-manifest older-iOS host **7 passed, 5 skipped**; Mac Catalyst
Essentials suite **272 passed, 8 skipped**.

Reproduced the missing event and stale Duo display metrics before the
fix. Verified the fixed behavior in running MAUI simulator apps, not
only assertions: closed/open/partial/refold transitions,
same-orientation screen handoff, both scene-enabled and no-manifest
lifecycles, older-runtime rotations, and multi-scene
activation/disconnection with subsequent fallback rotations. Checked
rendered screenshots and event/geometry traces. On the scene-enabled
Duo, opening changed the reported display from 1398 x 2034 portrait to
2853 x 2007 landscape without another physical-orientation notification.

#### Coverage limits

- Simulator validation only; physical-device confirmation is still
needed.
- The genuine no-manifest host was exercised locally, not added as a
separate CI host. UIKit's letterboxed compatibility mode keeps its
virtual display when unfolding; no event is expected when those metrics
do not change.
- One reused-simulator run hit a UIKit orientation-request timeout; the
focused fresh-simulator rerun and final full iOS run passed.
- The fail-without-fix helper was blocked before either phase with
`ERROR: COULD NOT FIND MERGE BASE`. The regression evidence above comes
from independent original-code reproductions and fixed-build runs, not a
successful helper verification.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #39182

Follow-up to #39398. Related closed alternative: #39403.

<!--
Are you targeting main? All PRs should target the main branch unless
otherwise noted.
-->

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
@jgold6
jgold6 deleted the patch-1 branch November 20, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community ✨ Community Contribution s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-review-in-progress AI review is currently running for this PR s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeviceDisplay.Current.MainDisplayInfo.Orientation always showing Portrait for iOS 27

4 participants