I created a simple MAUI project to troubleshoot built-in MAUI AppShell navigation.
I have a MainPage
(binded to a MainPageViewModel
) with a CollectionView
of ItemViewModel
.
I have added in XAML a Gesture behavior to respond to double tapping on each of presented ItemViewModel
, that will trigger a navigation to my second page : SelectPage
.
I have done the routing of the navigation in a relative way so I can go back with the built-in go back button in navigation bar.
I test this navigation from going back and forth between my 2 pages, until it break out with a Microsoft.UI.Xaml.Controls.Frame.NavigationFailed was unhandled.
unhandled exception in App.g.I.cs generated file.
It can happen in either way of navigation (either going to my second page or going back to my main page).
This exception occur after a while but with no special pattern (could be the 5th times or the 13th times of navigation e.g.).
(NOTE that when using ScreenToGif to record this issue on video, so far it always crash on the second navigation ?!)
Here is my simple project on GitHub for code review.
And here is my video to illustrate this issue
The stack trace showed in the end is :
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.Controls.IFrameMethods.Navigate(IObjectReference _obj, Type sourcePageType, Object parameter, NavigationTransitionInfo infoOverride)
at Microsoft.Maui.Platform.StackNavigationManager.NavigateTo(NavigationRequest args)
at Microsoft.Maui.CommandMapper.InvokeCore(String key, IElementHandler viewHandler, IElement virtualView, Object args)
at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.SyncNavigationStack(Boolean animated, NavigationRequestedEventArgs e)
at Microsoft.Maui.Controls.Handlers.ShellSectionHandler.OnNavigationRequested(Object sender, NavigationRequestedEventArgs e)
at Microsoft.Maui.Controls.ShellSection.InvokeNavigationRequest(NavigationRequestedEventArgs args)
at Microsoft.Maui.Controls.ShellSection.OnPushAsync(Page page, Boolean animated)
at Microsoft.Maui.Controls.ShellSection.PushStackOfPages(List`1 pages, Nullable`1 animate)
at Microsoft.Maui.Controls.ShellSection.GoToAsync(ShellNavigationRequest request, ShellRouteParameters queryData, IServiceProvider services, Nullable`1 animate, Boolean isRelativePopping)
at Microsoft.Maui.Controls.ShellNavigationManager.GoToAsync(ShellNavigationParameters shellNavigationParameters, ShellNavigationRequest navigationRequest)
at TestinMAUIPageNavigationPerf.Sources.ViewModels.ItemViewModel.SelectItem()