FreakyAli / Maui.FreakyControls

FreakyControls is a free OSS UI Kit for .NET MAUI which provides a set of controls and utilities to build modern mobile apps.
MIT License
313 stars 37 forks source link

[Android] InvalidOperationException in Maui app when switching shell tabs #155

Open janusw opened 1 month ago

janusw commented 1 month ago

Description

I see crashes with an InvalidOperationException on Android when using any of your controls in a MAUI app with shell tabs, whenever I switch the shell tabs to a page that contains one of your controls.

I first observed it with the FreakyPicker, but it also seems to occur with (all?) other controls.

To reproduce:

Code

See https://github.com/janusw/Maui.FreakyControls/tree/sample_with_shell_tabs

Expected Behavior

No crash.

Actual Behavior

The sample app crashes with this exception:

System.InvalidOperationException: PlatformView cannot be null here
  at Microsoft.Maui.Handlers.ViewHandler`2[[Microsoft.Maui.IDatePicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Platform.MauiDatePicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].get_PlatformView() in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:36
  at Maui.FreakyControls.FreakyDatePickerHandler.MapDatePicker(IDatePickerHandler datePickerHandler, IDatePicker datePicker) in MAUI.FreakyControls/FreakyDatePicker/FreakyDatePickerHandler.cs:19
  at Microsoft.Maui.PropertyMapperExtensions.<>c__DisplayClass3_0`2[[Microsoft.Maui.IDatePicker, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Microsoft.Maui.Handlers.IDatePickerHandler, Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<AppendToMapping>b__0(IDatePickerHandler handler, IDatePicker view, Action`2 action) in D:\a\_work\1\s\src\Core\src\PropertyMapperExtensions.cs:84

Basic Information

Reproduction Link

https://github.com/janusw/Maui.FreakyControls/tree/sample_with_shell_tabs

janusw commented 1 month ago

Seems very similar to #144 by @sk1llsh0t (which has been fixed in 0.5.0, right?).

janusw commented 1 month ago

Seems very similar to #144 by @sk1llsh0t (which has been fixed in 0.5.0, right?).

Oh, wait, apparently #144 has only been fixed on the develop branch so far, but not included in 0.5.0 😱

janusw commented 1 month ago

It actually looks like #145 fixes the problem (on the develop branch) for most of the controls. However, it still persists for the FreakyTimePicker (and maybe others, I haven't checked all of them yet).