Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

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 from this PR and let us know in a comment if this change resolves your issue. Thank you!

Description of Change

On iPadOS 26.1+, TabbedPage crashes with NullReferenceException in windowed apps < 667pt width. iOS 26.1 introduced early ViewDidLayoutSubviews() calls during UITabBarController base constructor execution for narrow viewports, before _viewHandlerWrapper initialization completes.

Fix: Add null-conditional operator to Element property getter:

- public VisualElement Element => _viewHandlerWrapper.Element ?? _element?.GetTargetOrDefault();
+ public VisualElement Element => _viewHandlerWrapper?.Element ?? _element?.GetTargetOrDefault();

The existing if (Element is IView view) guard in ViewDidLayoutSubviews() handles null safely.

Issues Fixed

Fixes #32661

Original prompt

Backport #32662


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Backport pull request #32662 from dotnet/maui Fix TabbedPage crash on iPadOS 26+ with narrow viewports Nov 19, 2025
Copilot AI requested a review from PureWeen November 19, 2025 13:03
@PureWeen PureWeen added this to the .NET 10.0 SR1.1 milestone Nov 19, 2025
@PureWeen PureWeen moved this to Ready To Review in MAUI SDK Ongoing Nov 19, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing Nov 19, 2025
@jfversluis jfversluis marked this pull request as ready for review November 19, 2025 16:05
Copilot AI review requested due to automatic review settings November 19, 2025 16:05
@jfversluis jfversluis merged commit 3081e5c into release/10.0.1xx-sr1 Nov 19, 2025
4 of 5 checks passed
@jfversluis jfversluis deleted the copilot/backport-pull-32662 branch November 19, 2025 16:06
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing Nov 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a NullReferenceException crash in TabbedPage on iPadOS 26.1+ when running in narrow viewports (< 667pt width). The crash occurs because iOS 26.1 introduced early ViewDidLayoutSubviews() calls during UITabBarController base constructor execution, before the _viewHandlerWrapper field is fully initialized.

Key Changes

  • Added null-conditional operator (?.) to the Element property getter to prevent dereferencing a null _viewHandlerWrapper during early lifecycle events
  • Added explanatory comment documenting the iPadOS 26.1+ behavior that necessitates this defensive code

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants