xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.87k forks source link

[Bug] DisplayActionSheet doesn't show up on macOS #15874

Open VitalyKnyazev opened 6 months ago

VitalyKnyazev commented 6 months ago

Description

iOS app crashes with NRE on MacOS 14+ when DisplayActionSheet is called because PopoverPresentationController there is always null. Corresponding MAUI issue https://github.com/dotnet/maui/issues/18156.

Steps to Reproduce

  1. Create an iOS app with ListView and context menu that has "More" item.
  2. Launch the app on Mac OS 14+
  3. Click "More" item.

Expected Behavior

No crash, and the popup has "Cancel" button as clicking outside popup does not dismiss it.

Actual Behavior

The app crashes with NRE.

Basic Information

Environment

Show/Hide Visual Studio info Microsoft Visual Studio Community 2022 Version 17.9.2 VisualStudio.17.Release/17.9.2+34622.214 Microsoft .NET Framework Version 4.8.09032 Installed Version: Community Visual C++ 2022 00482-90000-00000-AA136 Microsoft Visual C++ 2022 ASP.NET and Web Tools 17.9.197.37128 ASP.NET and Web Tools Azure App Service Tools v3.0.0 17.9.197.37128 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 17.9.197.37128 Azure Functions and Web Jobs Tools C# Tools 4.9.0-3.24121.1+a98c90d56455379836dd5c845b35fa932b00cfa3 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Extensibility Message Bus 1.4.39 (main@e8108eb) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Mono Debugging for Visual Studio 17.9.0 (b3bca6f) Support for debugging Mono processes with Visual Studio. NuGet Package Manager 6.9.1 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Razor (ASP.NET Core) 17.9.2.2412004+684740676513b3b208d5bd5b7f8786dab8d287b7 Provides languages services for ASP.NET Core Razor. SQL Server Data Tools 17.9.51.1 Microsoft SQL Server Data Tools TypeScript Tools 17.0.30103.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 4.9.0-3.24121.1+a98c90d56455379836dd5c845b35fa932b00cfa3 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 17.9.0-beta.23614.3+a521e1cd420beb56c15faf6836184fadd2b7937a Microsoft Visual F# Tools Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. VisualStudio.DeviceLog 1.0 Information about my package VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 17.9.0.138 (d17-9@60c2b9b) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 17.9.3.0 (remotes/origin/d17-9@f174974f91) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 17.9.0 (38e87ba) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14) Xamarin.Android Reference Assemblies and MSBuild support. Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d Xamarin.iOS and Xamarin.Mac SDK 16.4.0.23 (9defd91b3) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Screenshots

Show/Hide Exception info "innerExceptions": [ { "type": "System.NullReferenceException", "message": "Object reference not set to an instance of an object.", "stackTrace": " at Xamarin.Forms.Platform.iOS.Platform.PresentPopUp (UIKit.UIWindow window, UIKit.UIAlertController alert, Xamarin.Forms.Internals.ActionSheetArguments arguments) <0x106e519d4 + 0x00494> in <03af6754ca4e406c857676d299e3ed7d#5be0c0225d9b4a02a673e86b952ee248>:0 \n at Xamarin.Forms.Platform.iOS.Platform.PresentActionSheet (Xamarin.Forms.Internals.ActionSheetArguments arguments) <0x106e513dc + 0x0058b> in <03af6754ca4e406c857676d299e3ed7d#5be0c0225d9b4a02a673e86b952ee248>:0 \n at Xamarin.Forms.Platform.iOS.Platform+<>c__DisplayClass57_0.b__3 (Xamarin.Forms.Page sender, Xamarin.Forms.Internals.ActionSheetArguments arguments) <0x106e540d4 + 0x00027> in <03af6754ca4e406c857676d299e3ed7d#5be0c0225d9b4a02a673e86b952ee248>:0 \n at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)\n at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x104fe51d0 + 0x000ef> in :0 ", "wrapperSdkName": "appcenter.xamarin" } ],

Reproduction Link

N/A yet

Workaround

N/A, except patching and recompiling Xamarin.Forms package locally