Repository navigation
fix(responsive): release hosts that never load from HardSelfReferences - #1684
Conversation
- Install an extension on a host that is never loaded, so it never connects - Release the host, collect, sweep, collect again - Assert the host and the extension are both collected - Fails today: the pending Loaded unsubscription holds the host strongly, and the sweep never removes an extension that has no host weak-reference - Take the TrackedInstances baseline after a sweep, so dead entries left by earlier tests do not skew the count Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Capture the host weakly in the Loaded and Unloaded unsubscribe closures, so the static HardSelfReferences list cannot root the host through them - Judge a never-connected extension's liveness by its target, in both SweepDeadInstances and CleanupIfHostDisposed - Without this, an extension provided on an element that never loads stays in the static list forever and keeps its element tree alive; an app loaded in a collectible AssemblyLoadContext then cannot unload Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-1684.eastus2.azurestaticapps.net |
There was a problem hiding this comment.
🔵 Needs a closer look
Human validation is needed for the untested connected-host collection path and reported runtime-test failures, alongside correction of the pruning-test baseline.
1 open issue
What changed in this PR
Fixes responsive-extension retention of never-loaded elements, addressing issue #1683 and helping collectible app contexts unload.
Changes:
- Uses weak host references in both unsubscribe closures.
- Shares a liveness check that falls back to the target before connection.
- Adds a never-loaded-host regression test and adjusts pruning-test setup.
| File | Description |
|---|---|
| src/Uno.Toolkit.UI/Markup/ResponsiveExtension.cs | Weakens host captures and extends cleanup to never-connected instances. |
| src/Uno.Toolkit.RuntimeTests/Tests/ResponsiveExtensionsLeakTests.cs | Adds collection coverage and revises the pruning baseline. |
Review effort: Balanced
|
@Mergifyio backport servicing/10.0 |
✅ Backports have been createdDetails
|
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://polite-field-01aa64f0f-1684.eastus2.azurestaticapps.net |
…s (backport #1684) (#1685) Co-authored-by: Nick Randolph <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: Steve Bilogan <[email protected]>

GitHub Issue (If applicable): closes #1683
PR Type
What is the current behavior?
ResponsiveExtensionadds itself to the staticHardSelfReferenceslist (the uno#14502 workaround).AssemblyLoadContextcan't unload.What is the new behavior?
ConnectWhenLoaded,Connect) hold the host through aWeakReference.SweepDeadInstancesandCleanupIfHostDisposedshare one check,IsHostGone. It falls back to the target's weak reference when the extension never connected.Reviewer's guide
src/Uno.Toolkit.UI/Markup/ResponsiveExtension.cs,IsHostGoneand the twoDisposable.Createclosures.ResponsiveExtensionsLeakTests.NeverLoaded_Host_IsCollectible_AfterSweep. Without the fix it fails onAssert.IsFalse(hostRef.IsAlive).SweepDeadInstances_Prunes_CollectedTrackedInstancesnow takes its baseline count after a collect and sweep, so a dead entry left by another test can't skew it.Connectclosure. The case it guards is a connected host dropped withoutUnloaded, which the harness can't fake.ColumnDefinitionon aGridthat never loads.PR Checklist
net10.0-desktopOther information
Runtime tests, desktop, Debug, filter
Responsive: 12 passed, 2 failed, 7 skipped. The 2 failures areResponsiveHelperLeakTests.Reset_TearsDown_DefaultProviderandDefaultProvider_IsCollectible_WhileXamlRootAlive. Both time out waiting for "Border loaded", and fail the same way without this change.🤖 Generated with Claude Code