Repository navigation
fix(win32): Fix UIA provider memory leak (partial backport of #23722) - #25943
Merged
agneszitte merged 2 commits intoNov 2, 2026
Merged
Conversation
A UIA provider that a client still references after its element left the tree must not keep that element alive. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 18ead23)
An invalidated Win32RawElementProvider kept a strong reference to its UIElement, so any outstanding COM reference to the provider leaked the whole element subtree. Clear the owner on invalidation and fail owner reads with UIA_E_ELEMENTNOTAVAILABLE. Backport of the provider lifecycle part of #23722. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit c5e4707)
agneszitte
approved these changes
Nov 2, 2026
2 of 5 tasks
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: partial backport of #23722, same change as #25942 for 6.8 (related: unoplatform/kahua-private#564)
PR Type:
🐞 Bugfix
What changed? 🚀
On Win32, an element removed from the tree could stay in memory for as long as anything still held a COM reference to its UI Automation provider. An invalidated
Win32RawElementProviderkept a strong reference to itsUIElement, so the whole subtree stayed alive. The retention path in a memory dump is[COM/WinRT Objects] → Win32RawElementProvider → <element>.This backports the provider-lifecycle part of #23722 to
release/stable/6.7. The rest of that PR (a11y parity work) is left out.Win32RawElementProvider.Invalidate()clears its reference to the element.ConnectedOwner, which throwsUIA_E_ELEMENTNOTAVAILABLEon an invalidated provider, the same error UIA clients already get fromThrowIfDisconnected.DescribeElement(), used only for logging, returns a placeholder instead.Win32Accessibilityskips the provider's element when it has been cleared (lookup-table cleanup, live-region announcement).The new runtime test
Given_Win32Accessibility.When_Removed_Element_Provider_Is_Still_Referenced_Owner_Is_Collectedholds a COM reference to a removed element's provider and checks that the element is collected. Locally on Skia Win32 (SamplesApp.Skia.Generic, net10.0), it fails without the fix (181f20c2aa) and passes with it (087fb0efd4).PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code