enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
1.18k stars 143 forks source link

Windows - PlatformView cannot be null here #821

Open MitchBomcanhao opened 2 days ago

MitchBomcanhao commented 2 days ago

We recently started getting a lot of these exceptions on our windows client, namely when navigating away from pages or when replacing pages from the navigation stack. Something may have changed with .net 9 as we didn't have these beforehand but now our windows client is essentially unusable. I don't have a repro project I can offer but I have some context which may be useful.

on this previous issue on Android: https://github.com/enisn/UraniumUI/issues/590 the author claims that the handler methods seem to receive a valid platformView object but then do not use it in the method itself, eg

protected override void DisconnectHandler(AppCompatAutoCompleteTextView platformView)
{
    PlatformView.TextChanged -= PlatformView_TextChanged;
    PlatformView.EditorAction -= PlatformView_EditorAction;
    PlatformView.ItemClick -= PlatformView_ItemClicked;
}

They say that the method seems to work as expected when using platformView instead of PlatformView, but issues caution as they're not sure if this is the correct solution.

@enisn created a PR which makes that change - see https://github.com/enisn/UraniumUI/pull/591.

now, the failures I am seeing actually come from the InputKit.Maui package, which is a dependency of UraniumUI. if we look at its codebase, we can see the same kind of thing in the Windows StatefulGridHandler, also in the StatefulStackLayoutHandler,:

        protected override void ConnectHandler(LayoutPanel platformView)
        {
            PlatformView.PointerPressed += NativeView_PointerPressed;
            PlatformView.PointerReleased += NativeView_PointerReleased;
            PlatformView.PointerEntered += NativeView_PointerEntered;
            PlatformView.PointerExited += NativeView_PointerExited;
        }

        protected override void DisconnectHandler(LayoutPanel platformView)
        {
            PlatformView.PointerPressed -= NativeView_PointerPressed;
            PlatformView.PointerReleased -= NativeView_PointerReleased;
            PlatformView.PointerEntered -= NativeView_PointerEntered;
            PlatformView.PointerExited -= NativeView_PointerExited;
        }

For us the only workaround has been to stop using UraniumUI altogether as it completely breaks our application as is. I briefly tried the .net9 preview version of UraniumUI and it made no difference on this particular issue.