Skip to content

Hot reload can crash the process when apps run in collectible load contexts #3248

Closed

Description

@kazo0

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)

  1. In a host process, load app A into a collectible AssemblyLoadContext (with its own copy of Uno.Extensions.Navigation), then unload it.
  2. Load app B into a new collectible context while A is still being collected.
  3. Apply a hot-reload delta to B that adds or changes a page type.
  4. 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) plus AssemblyLoadContext.Default would follow what HotReloadAgent already does when it looks for update handlers.

Activity

  1. self-assigned this
    on Oct 15, 2026
  2. added
    kind/bug
    triage/untriaged
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/navigationkind/bugtriage/untriaged

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions