the49ltd / The49.Maui.BottomSheet

.NET MAUI library used to display pages as Bottom Sheets
MIT License
323 stars 30 forks source link

Entry / Editor Crashes When Focussed #108

Closed Axemasta closed 4 months ago

Axemasta commented 5 months ago

If you add an Entry / Editor to a BottomSheet on iOS, shortly after focussing the control there is a crash:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.AdjustPosition()
   at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.AdjustPositionDebounce()
   at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.DidUITextBeginEditing(NSNotification notification)
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2594
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 60
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at KeyboardAutoScrollRepro.Program.Main(String[] args) in /Users/axemasta/Documents/Dev/Projects/Maui/KeyboardAutoScrollRepro/KeyboardAutoScrollRepro/Platforms/iOS/Program.cs:line 13
2024-04-09 14:25:19.623589+0100 KeyboardAutoScrollRepro[88641:22091147] Unhandled managed exception: Object reference not set to an instance of an object. (System.NullReferenceException)
   at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.AdjustPosition()
   at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.AdjustPositionDebounce()
   at Microsoft.Maui.Platform.KeyboardAutoManagerScroll.DidUITextBeginEditing(NSNotification notification)
   at ObjCRuntime.Runtime.ThrowException(IntPtr gchandle) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/Runtime.cs:line 2594
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 60
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at KeyboardAutoScrollRepro.Program.Main(String[] args) in /Users/axemasta/Documents/Dev/Projects/Maui/KeyboardAutoScrollRepro/KeyboardAutoScrollRepro/Platforms/iOS/Program.cs:line 13

This is a crash from within Maui however I thought I would document on this project, since the issue only happens when using a bottom sheet.

The crash only happens when the page invoking the bottom sheet is a modal.

I have a public reproduction here and have raised the issue with maui so hopefully they can help get a fix.

SimonBrettschneider commented 5 months ago

I am facing the same issue. @Axemasta Did you find a solution or a workaround?

Axemasta commented 5 months ago

Did you find a solution or a workaround?

The only workaround I found is to not use modal pages, which doesn't really work for the apps I'm building!

I raised a PR on maui and i believe its going to be merged & included as part of .NET 8 SR5 since it was a bug in the Maui SDK causing this crash.

SimonBrettschneider commented 5 months ago

Did you find a solution or a workaround?

The only workaround I found is to not use modal pages, which doesn't really work for the apps I'm building!

I raised a PR on maui and i believe its going to be merged & included as part of .NET 8 SR5 since it was a bug in the Maui SDK causing this crash.

Thank you - I am looking forward to the fix :-)

Axemasta commented 4 months ago

This is fixed with Maui 8.0.40 SR5, I've tested with my app and the crash no longer happens 🥳