Repository navigation
fix(win32): Correct UIA structure event ABI - #25985
Conversation
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25985/docs/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243317 found UI Test snapshots differences: Details
|
|
Claude finished @morning4coffe-dev's task in 27s —— View job Review summaryVerdict: ship, with one non-blocking suggestion.
Code review (by inspection):
Cross-cutting:
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. |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
Claude finished @morning4coffe-dev's task in 17s —— View job Review summaryVerdict: ship, with one open item carried over from the earlier review.
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.
Open item. 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
left a comment
There was a problem hiding this comment.
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.8and which is from master. - The GC-based tests (
When_Removed_Subtrees_Have_Referenced_Providers_Then_All_Owners_Are_Collectedasserts collection of 36 owners) are structured sensibly, but they're the kind that can flake. Something to keep an eye on in CI.
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
Claude finished @morning4coffe-dev's task in 26s —— View job Review summaryVerdict: fix-first (minor). The ABI fix is correct and ready. Commit 3 and the test coverage have open items that earlier reviewers already raised.
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.
Cross-cutting concerns
|
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 243419 found UI Test snapshots differences: Details
|
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]>
|
Claude finished @Xiaoy312's task in 21s —— View job Review summaryVerdict: ship, with minor open items.
I read the latest commit ( Resolved by
Still open from earlier threads
Cross-cutting
I posted no new inline comments, because every line-level finding is already covered by an existing thread. |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-25985/docs/index.html |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
@Mergifyio backport release/stable/7.0 |
✅ Backports have been createdDetails
|
|
The build 243464 found UI Test snapshots differences: Details
|
|
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. |
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]>
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
UiaRaiseStructureChangedEventwith 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 onlyChildRemoved, which carries a runtime ID, crashed. The P/Invoke now passes anint[]plus its length, and 0 for a null runtime ID. No other P/Invoke inWin32UIAutomationInterop.cshas this mistake:UiaRaiseTextEditTextChangedEventreally does take aSAFEARRAY*.2. Lookups during provider cleanup (behaviour change).
UiaDisconnectProvidercalls back into the provider it is disconnecting:ProviderOptions,HostRawElementProvider,GetPropertyValue,Navigate(Parent),GetRuntimeIdandFragmentRoot. It does this even when no client has subscribed to the app's events.Navigate(Parent)resolves the parent throughGetProviderForPeer/GetOrCreateProvider. On master these lookups returned null whileCleanupProvidersran, even for a parent whose provider was still connected.During cleanup, the three lookups (
GetOrCreateProvider,GetProvider,GetOrCreateProviderForResolvedPeer) now share one lookup-only path: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_Changesneeds an out-of-process UIA client. A regular runtime-test run therefore reports it as inconclusive. The Windows Skia runtime-test job now runsbuild/test-scripts/Win32UiaEventProbeafter the main run and publishes its results.Validation
Runtime (Skia Win32, local,
Given_Win32ProviderLifetime):Win32UiaEventProbeChildAddedandChildRemovedmatched the runtime ID0xC0000005, and the probe failedWhen_Cleanup_Reenters_Live_Provider_Lookupfailed (provider registered only by its peer)Compile: desktop SamplesApp, Release
net10.0-desktop.Earlier evidence from the 6.x lines:
servicing/6.8crashed with0xC0000005in the three-argument call under the same subscription.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.servicing/6.8andrelease/stable/6.7candidates 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:
Backports:
release/stable/7.0via Mergify.servicing/6.8andrelease/stable/6.7get separate PRs: the 6.x code differs, and those PRs also carry the provider-cleanup part of #23722.PR Checklist ✅
Screenshots Compare Test Runresults. The 2458 changed snapshots also appear on fix(AnimatedIcon): Don't root the icon from its Foreground brush or State ancestor #25948, fix: Subscribe to Command.CanExecuteChanged weakly #25965 and fix(NavigationView): Don't root menu items from the SplitView #25968, so they're baseline noise; this PR has no visual change.