uno.extensions icon indicating copy to clipboard operation
uno.extensions copied to clipboard

App Layout Blanks Out When Navigating to Invalid Route

Open Kunal22shah opened this issue 1 year ago • 1 comments

Current behavior

When navigating to a route that matches a common type name with suffixes (e.g., List, resulting in ListView), the app goes blank and logs a warning: Uno.Extensions.Navigation.Navigators.ContentControlNavigator: Warning: CreateControlFromType - Type not registered ListView, so calling Activator.

Expected behavior

Navigating to a route that is not registered should handle the error and avoid causing the app to go blank/crash.

How to reproduce it (as minimally and precisely as possible)

  1. Create a new Uno App.
  2. Set up a navigation button with an invalid path using uen:Navigation.Request (e.g., List).
  3. Observe that navigating to this invalid path causes the app layout to go blank. Minimal Repro Project: NavigationBug.zip

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

  • [x] iOS
  • [ ] macOS (AppKit)
  • [ ] Mac Catalyst
  • [x] Android
  • [ ] WebAssembly
  • [x] Windows
  • [ ] Skia (WPF)
  • [ ] Skia (GTK on Linux/macOS/Windows)
  • [ ] Skia (Linux Framebuffer)
  • [ ] Build tasks

Visual Studio:

  • [ ] 2019 (version: )
  • [x] 2022 (version: )
  • [ ] Visual Studio Code (version: )
  • [ ] Rider Windows (version: )
  • [ ] Rider macOS (version: )

Relevant plugins:

  • [ ] Resharper (version: )

Anything else we need to know?

Original Issue : https://github.com/unoplatform/uno/issues/17238

The issue seems to stem from the type resolution logic in RouteResolverDefault: https://github.com/unoplatform/uno.extensions/blob/main/src/Uno.Extensions.Navigation.UI/RouteResolverDefault.cs#L149-L173 https://github.com/unoplatform/uno.extensions/blob/848ac33909af8b4f5c14fd42ed3f7424f23350ed/src/Uno.Extensions.Navigation.UI/RouteResolverDefault.cs#L9

Kunal22shah avatar Jun 21 '24 14:06 Kunal22shah

@nickrandolph, @eriklimakc, @kazo0 please sync with @francoistanguay if further discussions are needed regarding reserved route names to determine the expected fix for this issue please. (Initial discussion here).

The fix may involve for example:

  • Changing the current logic OR
  • Documenting names to avoid for routes, such as for example:
    • List (because ListView is a type)
    • XXXPage (because XXXPage is likely to be an actual page)
    • ... OR
  • Another solution depending on the discussion

agneszitte avatar Jul 18 '24 17:07 agneszitte

There has been documentation added surrounding this scenario as part of https://github.com/unoplatform/uno.extensions/pull/2317

See: https://github.com/unoplatform/uno.extensions/blob/main/doc/Learn/Navigation/HowTo-DefineRoutes.md#routemap

@eriklimakc / @vatsashah45 We should continue to investigate this and at least avoid the app crashing/going blank when a route like this is used. Perhaps just ignore the navigation and log a warning/error

fyi @agneszitte / @nickrandolph

kazo0 avatar Aug 14 '24 11:08 kazo0