-
Notifications
You must be signed in to change notification settings - Fork 519
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
ArgumentNullException on UIApplication.SupportedInterfaceOrientationsForWindow #22278
Comments
According to Apple's documentation, the [Export("application:supportedInterfaceOrientationsForWindow:")]
public UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application,
UIWindow? forWindow)
{
if (forWindow?.WindowScene != null && AllowRotation)
{
return UIInterfaceOrientationMask.All;
}
if (window is null)
return UIInterfaceOrientationMask.Portrait; // or whatever is desired for your app when there's no window
return application.SupportedInterfaceOrientationsForWindow(forWindow);
} |
@rolfbjarne I'm no iOS expert but I dont think the objective-c documentation has nullability info See https://developer.apple.com/documentation/uikit/uiapplicationdelegate/application(_:didfinishlaunchingwithoptions:) as another example of a method with a nullable input parameter launchOptions parameter can be null as shown in the Swift documentation but theres no indication in the Objective-C version of the page (that the pointer can be null). See https://developer.apple.com/documentation/uikit/uiapplication/supportedinterfaceorientations(for:) (no query string, Swift documentation) that marks window parameter as nullable The stack trace shows that clearly on some device under some conditions the method is being called with a null window The xamarin wrapper for GetSupportedInterfaceOrientations is generated with window as not nullable and I assume that means its injecting NativeObjectExtensions.GetNonNullHandle which is throwing |
OK, I see. I've prepared a fix, and this should be fixed in the next minor release. |
Apple platform
iOS
Framework version
net9.0-*
Affected platform version
MAUI 9.0.21
Description
Getting a crash report with the following stack trace
Apple marks the window parameter as nullable, but the generated code seems to be doing a null check.
Steps to Reproduce
My app is overriding supportedInterfaceOrientationsForWindow because we disallow rotation on all but one screen, so this can not be hardcoded in the info.plist
Crash is being reported for iPad Pro (12.9-inch) (3rd generation) running iOS 17.6, app in foreground
Did you find any workaround?
No response
Relevant logs
No response
The text was updated successfully, but these errors were encountered: