Repository navigation
fix(composition): Prune dead context entries on add (backport #26124) - #26152
Merged
Merged
Conversation
CompositionObject.AddContext appended a weak ContextEntry per consumer but never swept dead ones. A consumer (BorderVisual, CompositionSpriteShape, SpriteVisual) only removes its entry when its brush property is reassigned, so consumers that are simply collected left their entry on the brush. Shared theme/resource brushes rarely raise changes (PropagateChanged is the only other place that prunes), so their list and its WeakReference GC handles grew without bound (3 entries per Border+Rectangle using the brush). AddContext now sweeps dead entries once the list reaches a threshold, then resets the threshold to twice the surviving count (min 16): O(live consumers) size, amortized O(1) per add. The sweep is skipped while PropagateChanged is iterating the same list. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 4875228)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 41af0ca)
Conservative GC (WASM, mobile) can keep a consumer alive, which then legitimately keeps its entry. Derive the expected counts from the measured survivors instead of assuming every consumer was collected, and fail visibly if most of them were not. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 95ee120)
Contributor
Author
|
Cherry-pick of b393072 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
2 of 5 tasks
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 22504e2)
The XAML leak test now asserts the live Border and Rectangle keep their entries and still render a brush change after the sweep, and resets the window content. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit e94e47e)
6.x still keeps composition tests under Tests/Windows_UI_Composition and samples under Windows_UI_Composition. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Xiaoy312
force-pushed
the
mergify/bp/servicing/6.8/pr-26124
branch
from
November 6, 2026 17:47
9bbffdf to
34809d2
Compare
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Xiaoy312
approved these changes
Nov 8, 2026
Contributor
Author
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Merged
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes unoplatform/kahua-private#569
PR Type:
🐞 Bugfix
What changed? 🚀
A composition brush keeps a weak "context" entry (a
WeakReferenceand its GC handle) for every visual or shape that uses it, so it can propagate its changes. A consumer only removes its entry when its brush property is reassigned. Consumers that are simply unloaded and collected left their entry on the brush, and only a change of the brush pruned them. Shared theme/resource brushes rarely change, so their list grew without bound: 3 entries per Border + Rectangle that ever used the brush.CompositionObject.AddContextnow sweeps dead entries once the list reaches a threshold, then resets the threshold to twice the surviving count (minimum 16). The sweep is skipped whilePropagateChangedwalks the same list.Given_CompositionObject_Context. They fail without the fix (1000 / 1050 / 303 entries) and pass with it. The expected counts include any consumers the GC failed to collect (conservative stack scanning on WASM / mobile), and a test fails visibly if more than 10% stay alive. The XAML test also checks that the live Border and Rectangle still render a brush change after the sweep.CompositionBrushContextLeakin SamplesApp.The fix commit is the reporter's patch, kept verbatim; follow-ups are separate commits.
PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
This is an automatic backport of pull request #26124 done by [Mergify](https://mergify.com).