Repository navigation
Closed
Closed
Copy link
Labels
area/navigationkind/bugSomething isn't workingtriage/untriagedIndicates an issue requires triaging or verification.
Description
Current behavior
A host that loads apps into collectible AssemblyLoadContexts, and unloads one app before loading the next, can crash with an AccessViolationException on the first hot-reload update after the new app loads:
Fatal error.
System.AccessViolationException: Attempted to read or write protected memory.
at Uno.Extensions.Navigation.RouteResolverDefault+<>c.<get_LoadedTypes>b__26_3(...)
at Uno.Extensions.EnumerableExtensions.ToDictionaryDistinct(...)
at Uno.Extensions.Navigation.RouteResolverDefault.get_LoadedTypes()
at Uno.Extensions.Navigation.RouteResolverDefault.TypeFromPath(...)
at Uno.Extensions.Navigation.RouteResolverDefault.InternalDefaultMapping(...)
at Uno.Extensions.Navigation.RouteResolverDefault.InternalFindByView(Type)
at Uno.Extensions.Navigation.UI.NavigationRouteUpdateHandler.HasRouteRegisteredType(...)
at Uno.Extensions.Navigation.UI.NavigationRouteUpdateHandler.RebuildRoutes(...)
at Uno.Extensions.Navigation.UI.NavigationRouteUpdateHandler.UpdateApplication(Type[])
at Uno.UI.RemoteControl.HotReload.MetadataUpdater.HotReloadAgent...
RouteResolverDefault.LoadedTypes builds its type map from AppDomain.CurrentDomain.GetAssemblies(). That includes the assemblies of every other load context in the process, including one that is still being unloaded, and reflecting over those types is what crashes.
Expected behavior
- The route resolver only considers types its own app can see: its own load context plus the default one.
- Hot reload of one app never reads types belonging to another app.
How to reproduce it (as minimally and precisely as possible)
- In a host process, load app A into a collectible
AssemblyLoadContext(with its own copy ofUno.Extensions.Navigation), then unload it. - Load app B into a new collectible context while A is still being collected.
- Apply a hot-reload delta to B that adds or changes a page type.
- Intermittently, the process crashes in
RouteResolverDefault.get_LoadedTypes.
Steps 1–3 run many times a day in our CI; the crash shows up a few times a day.
Environment
Nuget Package (s): Uno.Extensions.Navigation.UI
Package Version(s): 7.4.0-dev.54
Affected platform(s):
- Skia (Linux X11), desktop
- Others not tested
Anything else we need to know?
- Related: Uno.Extensions.Navigation.UI semantics around thread safety, loaded assemblies #2943 raises the same
GetAssemblies()caching question, but not the multi-load-context case. - Because the map is keyed by simple type name, it can also resolve a route to the same-named type of another app.
- A fix scoped to
AssemblyLoadContext.GetLoadContext(typeof(RouteResolverDefault).Assembly)plusAssemblyLoadContext.Defaultwould follow whatHotReloadAgentalready does when it looks for update handlers.
Metadata
Metadata
Assignees
Labels
area/navigationkind/bugSomething isn't workingtriage/untriagedIndicates an issue requires triaging or verification.
Activity
ci: run the navigation unit tests in the package build
test(navigation): scope implicit route lookup to the resolver's load …
fix(navigation): only resolve implicit routes from the resolver's own…
ci: run the navigation unit tests in the package build
test(navigation): scope implicit route lookup to the resolver's load …
fix(navigation): only resolve implicit routes from the resolver's own…
test(navigation): cover skipping the default copy of an assembly the …
fix(navigation): keep the unresolved-path warning and tidy the load-c…
ci: keep transitive pinning on for the navigation unit tests
test(navigation): cover the resolver's own-context choice and sibling…
refactor(navigation): extract the route type index so its tests run w…
fix(navigation): compare load-context assembly names case-insensitively
docs(navigation): note which load contexts implicit route lookup sear…
test(navigation): cover the resolver's own-context choice and sibling…
refactor(navigation): extract the route type index so its tests run w…
fix(navigation): compare load-context assembly names case-insensitively
docs(navigation): note which load contexts implicit route lookup sear…
test(navigation): cover the resolver's own-context choice and sibling…
refactor(navigation): give the route type index one entry point and d…
fix(navigation): build the route type index once when first lookups race
fix(navigation): keep the loadable types of an assembly whose types p…
fix(navigation): name the searched load contexts when an implicit rou…
docs(navigation): document AssemblyExtensions and what implicit route…