You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ALC teardown does not prune SystemNavigationManager event subscriptions #24074
A guest (secondary-ALC) app that subscribes to the process-wide SystemNavigationManager.GetForCurrentView().BackRequested is never unsubscribed by ALC teardown. PruneCollectibleAlcEventSubscriptions does not cover this singleton's event fields (_backRequested, InternalBackRequested).
The stale handler roots the guest's Shell and, through it, the guest's entire visual tree and its ALC. Verified via heap dump.
This is reachable from ordinary app code: the Uno.Themes sample Shell subscribes to BackRequested exactly as a normal app would.
Expected behavior
ALC teardown prunes BackRequested subscriptions originating from the unloading context, and the guest visual tree becomes collectible.
How to fix
Include the SystemNavigationManager event fields in the per-ALC event subscription sweep, pruning handlers whose target (or, for static handlers, declaring module) lives in a collectible ALC:
varoriginAssembly=handler.Target?.GetType().Assembly??handler.Method.Module.Assembly;vartargetAlc=AssemblyLoadContext.GetLoadContext(originAssembly);if(targetAlcis not null&&targetAlc!=AssemblyLoadContext.Default){pruned=Delegate.Remove(pruned,handler);}
Reproduced against Uno.Sdk.Private6.7.0-dev.815 (artifacts/uno @ 21bf1ad6), Skia desktop (X11 + Win32) and browserwasm, hosting the three Uno.Themes sample heads as secondary-ALC guests through AlcContentHost / WindowHelper.ContentHostOverride.
Activity