-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix TabbedPage crash on iPadOS 26+ with narrow viewports #32662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
/azp run MAUI-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Fix confirmed #32661 (comment) |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this 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 crash in TabbedPage on iPadOS 26.1+ when apps use narrow viewports (< 667 points width). The crash occurs due to iOS calling ViewDidLayoutSubviews() during the UITabBarController base constructor, before the derived class TabbedRenderer has initialized its _viewHandlerWrapper field.
Key Changes:
- Added null-conditional operator to
Elementproperty getter to handle early lifecycle calls - Added explanatory comment documenting the iOS version and viewport width condition
|
/backport to release/10.0.1xx-sr1 |
|
Started backporting to |
|
/rebase |
|
@PureWeen backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Patch format detection failed.
Error: The process '/usr/bin/git' failed with exit code 128 |
Add null-conditional operator to Element property getter to handle early ViewDidLayoutSubviews callback Co-authored-by: jfversluis <[email protected]>
00a8216 to
0a76a68
Compare
|
/backport to release/10.0.1xx-sr1 |
|
/azp run |
|
Started backporting to |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
@PureWeen backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Patch format detection failed.
Error: The process '/usr/bin/git' failed with exit code 128 |
<!-- 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! ### 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: ```diff - 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 <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > Backport #32662 </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
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+ with windowed apps < 667pt width,
TabbedPagecrashes during initialization withNullReferenceExceptioninTabbedRenderer.get_Element().Root cause: iOS 26.1+ calls
ViewDidLayoutSubviews()duringUITabBarControllerbase constructor execution in narrow viewports. This occurs before the derivedTabbedRendererconstructor body runs, leaving_viewHandlerWrapperuninitialized whenElementproperty is accessed.Fix: Add null-conditional operator to
Elementproperty getter:The existing
if (Element is IView view)pattern inViewDidLayoutSubviews()already handles null safely.Issues Fixed
Fixes #32661
Original prompt
This section details on the original issue you should resolve
<issue_title>TabbedPage crashes on iPadOS 26.1 with windowed applications in narrow viewports</issue_title>
<issue_description>### Description
When a .NET MAUI application initializes a
TabbedPagewith its default handler (Handlers.Compatibility.TabbedRenderer) in a windowed application with a width of 667 points or less on iPadOS 26.1, the application crashes with a null reference exception deep within the framework code. When the window width exceeds 667 points, theTabbedPageand its contents load and display properly.Stack Trace