Skip to content

fix(win32): Correct UIA structure event ABI - #25985

Merged
morning4coffe-dev merged 6 commits into
masterfrom
fix/win32-uia-cleanup-7.0
Nov 4, 2026
Merged

morning4coffe-dev merged 6 commits into
masterfrom
fix/win32-uia-cleanup-7.0

Conversation

@morning4coffe-dev

@morning4coffe-dev morning4coffe-dev commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: related to unoplatform/kahua-private#564

PR Type:

🐞 Bugfix

What changed? 🚀

1. Structure-event ABI (the crash). While a UI Automation client is subscribed to structure changes, removing an element can crash in UiaRaiseStructureChangedEvent with an access violation (0xC0000005). The native signature is (IRawElementProviderSimple*, StructureChangeType, int* pRuntimeId, int cRuntimeIdLen). Our P/Invoke marshalled the runtime ID as a SAFEARRAY and omitted the length, so only ChildRemoved, which carries a runtime ID, crashed. The P/Invoke now passes an int[] plus its length, and 0 for a null runtime ID. No other P/Invoke in Win32UIAutomationInterop.cs has this mistake: UiaRaiseTextEditTextChangedEvent really does take a SAFEARRAY*.

2. Lookups during provider cleanup (behaviour change). UiaDisconnectProvider calls back into the provider it is disconnecting: ProviderOptions, HostRawElementProvider, GetPropertyValue, Navigate(Parent), GetRuntimeId and FragmentRoot. It does this even when no client has subscribed to the app's events. Navigate(Parent) resolves the parent through GetProviderForPeer / GetOrCreateProvider. On master these lookups returned null while CleanupProviders ran, even for a parent whose provider was still connected.

During cleanup, the three lookups (GetOrCreateProvider, GetProvider, GetOrCreateProviderForResolvedPeer) now share one lookup-only path:

  • They try the peer key first, then the owner's element key, and accept the element-keyed provider only when it represents the same peer.
  • They never create a peer or a provider, and they never write the lookup tables.

Creation stays blocked during cleanup, so a callback can't create a provider for an element that was just cleaned.

3. CI coverage of the ABI fix. When_Native_Client_Observes_Structure_Changes needs an out-of-process UIA client. A regular runtime-test run therefore reports it as inconclusive. The Windows Skia runtime-test job now runs build/test-scripts/Win32UiaEventProbe after the main run and publishes its results.

Validation

Runtime (Skia Win32, local, Given_Win32ProviderLifetime):

Build Regular run With Win32UiaEventProbe
This PR 5 passed, 1 inconclusive 6/6 passed; ChildAdded and ChildRemoved matched the runtime ID
Signature reverted to the SAFEARRAY form 5 passed, 1 inconclusive (green) the app crashed with 0xC0000005, and the probe failed
Cleanup lookup before the lookup-only change When_Cleanup_Reenters_Live_Provider_Lookup failed (provider registered only by its peer) —

Compile: desktop SamplesApp, Release net10.0-desktop.

Earlier evidence from the 6.x lines:

  • Unpatched servicing/6.8 crashed with 0xC0000005 in the three-argument call under the same subscription.
  • Retained owners and a missed redirected-peer provider also reproduced on servicing/6.8. Their fix (the provider cleanup from feat(a11y): WinUI-parity accessibility fixes for Skia (Win32/macOS/WASM) #23722) is already on master, not in this PR.
  • The prepared servicing/6.8 and release/stable/6.7 candidates passed 6/6 with the probe.

Not resolved by this PR: the Kahua retention. In the Kahua desktop app (Uno.WinUI 6.7.135 with the patched 6.7 Win32 runtime), Close Record Detail unloads the view. The view's weak reference still survives repeated full GC and finalizer waits, even after the native client detaches (36 structure events received). That retention is tracked separately on the issue. This PR fixes the crash and the cleanup lookups, so it does not close the issue.

To run the native regression locally after building SamplesApp:

dotnet run --project build/test-scripts/Win32UiaEventProbe -- <absolute-path-to-SamplesApp.dll> <absolute-path-to-results.xml>

Backports: release/stable/7.0 via Mergify. servicing/6.8 and release/stable/6.7 get separate PRs: the 6.x code differs, and those PRs also carry the provider-cleanup part of #23722.

PR Checklist ✅

@github-actions github-actions Bot added area/build Categorizes an issue or PR as relevant to build infrastructure kind/documentation labels Nov 3, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243317 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AnimatedBackVisualSourceSamplePage.png
    • AppBarButtonTest.png-dark
    • AnimatedVisualsTestbedPage.png-dark
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSpanningRectsPage.png-dark
    • ApplicationViewSpanningRectsPage.png
    • AppWindowFeatures.png-dark
    • AppWindowFeatures.png
    • AppWindowTitleBar Properties.png-dark
    • AppXamlDefinedResources.png-dark
    • Arrange_Performance01.png-dark
    • Attributed_text_FontSize_Changing.png
    • AuthenticationBroker_Cancel.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithrightmargin.png-dark
    • AutomationProperties_AutomationId.png
    • AutomationProperties_Landmark.png
    • AutomationProperties_Landmark.png-dark
    • AutomationProperties_Name.png-dark
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png
    • AppBarToggleButtonTest.png-dark
    • ApplicationViewSizing.png
    • AppWindowClosing.png
    • AppWindowPresenters.png
    • Arrange_Performance01.png-dark
    • Attributed_text_Supserscript.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutomationPropertiesExtensions_Role.png-dark
    • AutomationPropertiesExtensions_Role.png
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_SoftKeboard.png
    • Basics_Automated.png-dark
    • Basics_Automated.png
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
    • BorderImageBrush.png-dark
    • BorderImageBrush.png

@morning4coffe-dev
morning4coffe-dev marked this pull request as ready for review November 3, 2026 19:29
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 27s —— View job


Review summary

Verdict: ship, with one non-blocking suggestion.

Severity Count
Blocking 0
Suggestion 1 (inline)

Code review (by inspection):

  • The P/Invoke change is correct. UiaRaiseStructureChangedEvent(provider, type, int* runtimeId, int cRuntimeIdLen) takes a raw int* plus a length. [MarshalAs(UnmanagedType.LPArray)] int[]? with runtimeId?.Length ?? 0 matches that signature and passes null with zero length. This is a root-cause fix: it corrects the ABI at the call site. It is not a guard.
  • The Path.Combine CodeQL findings are already resolved, because the current code uses Path.Join.
  • The "calls to unmanaged code" finding is a false positive, as the author noted.

Cross-cutting:

  • The native-client regression only runs when the manual probe is executed. In normal CI runs, When_Native_Client_Observes_Structure_Changes is inconclusive (see the inline comment).
  • The snapshot-diff comment reports 2458 of 2492 screenshots changed on both the Linux and Windows legs. This PR changes no rendering code, so the diff looks like a baseline or infrastructure problem. Please check it before merging.

Validation: I did not build or run anything. This review is based on reading the code. The PR's compile and runtime results are the author's own claims, and I haven't reproduced them.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 17s —— View job


Review summary

Verdict: ship, with one open item carried over from the earlier review.

Severity Count
Blocking 0
Suggestion 1 (existing inline thread)

Code review (by inspection only). I did not build or run anything. The compile and runtime results in the PR description are the author's own claims.

  • ABI fix (root-cause fix): UiaRaiseStructureChangedEvent now takes an int[] and its length, and passes 0 for a null runtime ID. That matches the native (provider, type, int*, int) signature. Nothing here is a guard.
  • Latest commit (11e37748): the _providerCleanupDepth check now runs after the cache lookup in GetOrCreateProvider, GetProvider and GetOrCreateProviderForResolvedPeer. Existing providers can still be resolved during cleanup, and new ones are not created. This looks consistent. The runtime tests for it cover the removed view and its descendant provider.
  • Path.Combine → Path.Join: already done in c2ced452.

Open item. When_Native_Client_Observes_Structure_Changes calls Assert.Inconclusive when UNO_UIA_STRUCTURE_PROBE is unset, which is the case in every normal CI run. AGENTS.md says to flag Assert.Inconclusive, and the crash regression can't fail CI as written. I'd either run Win32UiaEventProbe from a Windows CI step or keep that test out of default discovery. The inline thread from the earlier review already covers this.

Screenshot diffs. The snapshot comparison reports 2458 of 2492 screenshots changed on both Linux and Windows. This PR touches only the Win32 accessibility runtime, tests and a build script, so it points to a baseline or infrastructure problem. Please confirm that before checking the "Screenshots Compare" box.

@Xiaoy312 Xiaoy312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ABI fix itself looks right: the native signature is (IRawElementProviderSimple*, StructureChangeType, int* pRuntimeId, int cRuntimeIdLen), so the old SAFEARRAY + missing length explains why only ChildRemoved (non-null runtime ID) crashed. I also checked the other P/Invokes in Win32UIAutomationInterop.cs for the same mistake; UiaRaiseTextEditTextChangedEvent genuinely takes a SAFEARRAY* and the VARIANT/BSTR ones are fine, so this was the only bad one.

Main concerns are inline: the crash regression doesn't run in CI, and commit 3 is a separate behaviour change that the description doesn't explain.

Two more notes that don't fit a line:

  • The description says "the original checkout also reproduced retained owners and a missed redirected-peer provider before the lifecycle correction". That correction is already on master, not in this PR, so for a master reviewer it reads as if this PR fixes it. Worth clarifying which evidence is from servicing/6.8 and which is from master.
  • The GC-based tests (When_Removed_Subtrees_Have_Referenced_Providers_Then_All_Owners_Are_Collected asserts collection of 36 owners) are structured sensibly, but they're the kind that can flake. Something to keep an eye on in CI.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@morning4coffe-dev
morning4coffe-dev marked this pull request as draft November 3, 2026 20:46
@morning4coffe-dev
morning4coffe-dev marked this pull request as ready for review November 3, 2026 20:46
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @morning4coffe-dev's task in 26s —— View job


Review summary

Verdict: fix-first (minor). The ABI fix is correct and ready. Commit 3 and the test coverage have open items that earlier reviewers already raised.

Severity Count
Blocking 0
Should-fix 2 (both already in existing threads)
New inline comments 0

I didn't post new inline comments. Every line-level issue I found is already covered by an open thread, and I didn't want to duplicate them.

Code review (by inspection only). I did not build or run anything. The compile and runtime results in the description are the author's claims.

  • ABI fix (202843b6), root-cause fix: UiaRaiseStructureChangedEvent now passes an int[] plus its length, and passes 0 for a null runtime ID. That matches the native (provider, type, int*, int) signature.
  • Cleanup lookup (11e37748), behaviour change: GetOrCreateProvider, GetProvider and GetOrCreateProviderForResolvedPeer now return cached live providers during cleanup. They still refuse to create new ones while _providerCleanupDepth > 0.
    • Inconsistent gate: the gate in GetOrCreateProviderForResolvedPeer (Win32Accessibility.cs:330) still sits before the element-keyed fallback. During cleanup, a peer whose live provider is registered only under its element key resolves to null, while the other two methods find it. Xiaoy312 raised this.
    • Undocumented symptom: the description doesn't say which native callback re-enters, or what the symptom was before this commit. The Kahua tree loss is mentioned only in passing.

Cross-cutting concerns

  1. The crash regression doesn't run in CI. When_Native_Client_Observes_Structure_Changes returns Assert.Inconclusive unless UNO_UIA_STRUCTURE_PROBE is set. AGENTS.md says to flag that, and a revert of the ABI fix would not fail CI. Either wire Win32UiaEventProbe into the Windows leg, or add a cheap in-CI guard such as a reflection check on the P/Invoke signature.
  2. The cleanup-reentry test depends on a private field. It sets _providerCleanupDepth by reflection, so a rename breaks it without any real regression. It also doesn't exercise a real re-entrant callback.
  3. The PR is no longer a draft, but its description says to keep it draft. It says customer collection is unverified: the Kahua ItemView weak reference survives GC. The ABI fix stands on its own. Please either split the lifetime work out, or reword the description so the merge isn't taken to resolve the Kahua retention.
  4. The description mixes evidence from different branches. The "retained owners / missed redirected-peer provider" evidence is from the original checkout, and that lifecycle fix is already on master. Label which results come from servicing/6.8 and which from master.
  5. GC-based tests can flake. The 36-owner collection test is the likely one.
  6. Screenshot diffs. The comparison reports 2458 of 2492 screenshots changed on both Linux and Windows. This PR touches no rendering code, so it looks like a baseline or infrastructure problem. Please confirm that before ticking "Screenshots Compare".
  7. Probe nits:
    • The probe marker directory is never deleted.
    • Given_Win32ProviderLifetime still uses Path.Combine for the marker files.
    • The comment on the MTA thread in Win32UiaEventProbe/Program.cs is slightly inaccurate.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243419 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • Accessibility_ScreenReader.png-dark
    • AnimatedIconPage.png-dark
    • AnimatedVisualsTestbedPage.png-dark
    • AppBarButtonWithIconTest.png
    • ApplicationViewMode.png
    • AppBar_KeyBoard.png
    • AppWindowClosing.png
    • ApplicationViewSpanningRectsPage.png
    • AppWindowPresenters.png-dark
    • AppWindowPositionAndSize.png-dark
    • ArcSegment.png-dark
    • AppXamlDefinedResources.png
    • Attributed_text_Simple.png
    • Attributed_text_Simple.png-dark
    • AutomationProperties_Name.png
    • AuthenticationBroker_Cancel.png-dark
    • AutoSizedTopLeft.png-dark
    • AutoBorderStretchwithtopmargin.png-dark
    • AutoSizedTopLeft.png
    • AutoBorderStretchwithtopmargin.png
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedIconPage.png
    • AnimatedVisualsTestbedPage.png-dark
    • AppBarButtonWithIconTest.png
    • ApplicationViewSizing.png-dark
    • AppWindowClosing.png-dark
    • AppWindowPresenters.png-dark
    • AppXamlDefinedResources.png
    • Attributed_text_Simple.png-dark
    • AuthenticationBroker_Demo.png
    • AutoBorderStretchwithbottommargin.png-dark
    • AutomationProperties_Relations.png-dark
    • AutomationProperties_Relations.png
    • AutoSuggestBox_Icons.png-dark
    • AutoSuggestBox_Icons.png
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • BitmapImage_vs_SvgImageSource.png-dark
    • BitmapImage_vs_SvgImageSource.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png

@Xiaoy312 Xiaoy312 self-assigned this Nov 3, 2026
Xiaoy312 and others added 3 commits November 3, 2026 18:16
UiaDisconnectProvider calls back into the provider it disconnects,
including Navigate(Parent), even when no UIA client has subscribed to
the app's events. While CleanupProviders runs,
GetOrCreateProviderForResolvedPeer still checked the cleanup gate
before its element-keyed match and could create a peer and write the
lookup tables (RegisterPopupPanelAlias), while GetOrCreateProvider and
GetProvider tried only the element key, missing providers registered
by peer.

During cleanup all three now use one lookup: the peer key, then the
owner's element key when its provider represents the same peer. It
never creates a peer or a provider and never registers an alias.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Delete the probe's marker folder when it finishes, correct the comment
on why the client runs out of process, and join the marker paths with
Path.Join in the runtime test too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When_Native_Client_Observes_Structure_Changes is inconclusive without
an out-of-process UIA client, so restoring the SAFEARRAY signature of
UiaRaiseStructureChangedEvent passed every runtime test. Run
Win32UiaEventProbe after the Windows Skia runtime tests and publish its
results. Locally, with the signature reverted, the probe fails with the
access violation (0xC0000005) while the regular run stays green.

CI installs only the .NET 11 SDK, so the probe rolls forward to the
next major runtime, as Uno.NUnitTransformTool does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @Xiaoy312's task in 21s —— View job


Review summary

Verdict: ship, with minor open items.

Severity Count
Blocking 0
Should-fix 0
Nits 2

I read the latest commit (068ed8f6) and its diff. I did not build or run anything, so the compile and runtime results in the description are still the author's own claims.

Resolved by 068ed8f6

  • The main CI gap from the earlier reviews is closed. build/ci/tests/.azure-devops-tests-desktop-windows.yml now runs Win32UiaEventProbe after the Windows Skia runtime tests. It fails the job on a non-zero exit and publishes the results with failTaskOnMissingResultsFile.
  • The commit message says that with the SAFEARRAY signature restored, the probe fails with 0xC0000005 while the regular run stays green. That is the fail-before evidence needed for the ABI fix, and the probe is a root-cause regression check rather than a guard.
  • When_Native_Client_Observes_Structure_Changes is still Assert.Inconclusive in ordinary runs. It now has a real counterpart that fails CI, so I no longer consider it a problem.

Still open from earlier threads

  • Cleanup gate: GetOrCreateProviderForResolvedPeer should be consistent with GetProvider and GetOrCreateProvider. Commit e4c9bfc8 ("lookup-only") looks like it addresses this, but Xiaoy312's thread is still the place to confirm it.
  • Cleanup-reentry test: it sets the private _providerCleanupDepth field by reflection. That is brittle, but it is acceptable as long as the field name is kept in sync.
  • Probe nits:
    • The .probe-<guid> marker directory is never deleted.
    • Given_Win32ProviderLifetime still uses Path.Combine for the marker files.

Cross-cutting

  • Description: it mixes evidence from servicing/6.8, release/stable/6.7 and master. Please label which result comes from which branch.
  • Kahua retention: it is explicitly unresolved, so merging this PR should not be read as fixing it. The closes unoplatform/kahua-private#564 line suggests otherwise, so consider refs instead of closes unless that is intended.
  • Screenshot diffs: the comparison reports 2458 of 2492 screenshots changed on both legs. This PR touches no rendering code, so it points to a baseline or infrastructure problem. Please confirm that before ticking "Screenshots Compare".
  • GC tests: the 36-owner GC-based test could flake. Watch it in CI.

I posted no new inline comments, because every line-level finding is already covered by an existing thread.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@Xiaoy312

Xiaoy312 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@Mergifyio backport release/stable/7.0

@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/7.0

✅ Backports have been created

Details

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 243464 found UI Test snapshots differences: skia-linux-screenshots: 2458, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AppBarButtonWithIconTest.png-dark
    • AppBar_KeyBoard.png-dark
    • ApplicationViewSpanningRectsPage.png
    • AppWindowPositionAndSize.png-dark
    • AppXamlDefinedResources.png
    • Attributed_text_Simple.png-dark
    • Attributed_text_Supserscript.png-dark
    • AutoBorderStretchwithbottommargin.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutomationProperties_Landmark.png-dark
    • AutomationProperties_Landmark.png
    • AutoSuggestBox_Keyboard.png-dark
    • AutoSuggestBox_Keyboard.png
    • BasicAutoSuggestBox.png-dark
    • BasicAutoSuggestBox.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Foreground.png-dark
    • BitmapIcon_Foreground.png
  • skia-windows-screenshots: 2458 changed over 2492

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png-dark
    • AppBarButtonTest.png
    • AppBar_KeyBoard.png
    • ApplicationViewSpanningRectsPage.png
    • AppWindowPositionAndSize.png
    • Arrange_Performance01.png-dark
    • Attributed_text_Simple.png
    • AuthenticationBroker_Cancel.png-dark
    • AutoBorderStretchwithbottommargin.png
    • AutoBorderStretchwithleftmargin.png-dark
    • AutomationProperties_Landmark.png-dark
    • AutomationProperties_Landmark.png
    • AutoSuggestBox_BitmapIcon.png-dark
    • AutoSuggestBox_BitmapIcon.png
    • BadgeNotificationTests.png-dark
    • BadgeNotificationTests.png
    • Basics.png-dark
    • Basics.png
    • BindableDrawerLayout_ChangePane.png-dark
    • BindableDrawerLayout_ChangePane.png

@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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.

@Xiaoy312 Xiaoy312 added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 4, 2026
@morning4coffe-dev
morning4coffe-dev merged commit a728dec into master Nov 4, 2026
83 checks passed
@morning4coffe-dev
morning4coffe-dev deleted the fix/win32-uia-cleanup-7.0 branch November 4, 2026 10:14
Xiaoy312 pushed a commit to mikernet/uno that referenced this pull request Nov 6, 2026
Backport of the provider-cleanup part of unoplatform#23722 (master), complementing the
owner release already backported to 6.x, with the cleanup-lookup correction
from unoplatform#25985.

While a UIA client subscribes to StructureChanged events, providers of a
removed subtree could stay connected and never be invalidated, so UIA's COM
reference kept each provider, and through its owner the removed element tree,
alive:

- CleanupProviders walks the removed subtree top-down. Invalidating a
  provider calls UiaDisconnectProvider, during which UIA asks for its
  parent; the parent was cleaned a moment earlier, so a new provider was
  created for it and never invalidated. While a cleanup runs
  (_providerCleanupDepth), lookups now only return providers that already
  exist (peer key, then the owner's element key when it represents the
  same peer) and never create or register one. Lookups are not blocked
  outright: a connected parent must still resolve during the callback.
- Providers registered only by automation peer (e.g. realized
  ListViewItems) are not in the element-keyed table, so the cleanup walk
  skipped them. CleanupProviders now resolves providers with
  TryGetExistingProviderForElement.

Measured in an app that swaps record views in and out of a peer-bearing
container, with a UIA client subscribed to StructureChanged (Subtree):
18 of 18 closed record views were retained on 6.8.0-dev.311, with the root
path [COM/WinRT Objects] -> Win32RawElementProvider -> view. With this change,
none are retained through a provider and the heap levels off.

Adds the Given_Win32ProviderLifetime runtime tests from unoplatform#25985, without the
native-client test that needs the out-of-process probe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.0 PRs only. For issues, use the Release field. area/build Categorizes an issue or PR as relevant to build infrastructure do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants