Skip to content

perf(win32): Stop raising UIA bounds changes on layout (6.8) - #24786

Merged
agneszitte merged 3 commits into
servicing/6.8from
dev/mazi/68-win32-uia-bounds
Oct 2, 2026
Merged

agneszitte merged 3 commits into
servicing/6.8from
dev/mazi/68-win32-uia-bounds

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24784

PR Type:

🐞 Bugfix (performance)

What changed? 🚀

Win32Accessibility.OnSizeOrOffsetChanged raised a UIA BoundingRectangle property-changed event for every element whose visual moved or resized. On most desktops a UIA client is listening (PowerToys, TextInputHost and Chromium browsers all register as one; UiaClientsAreListening() returned true on the test machine). So every scroll frame paid a native UiaRaiseAutomationPropertyChangedEvent call per realized element, and a listener gate alone would not help.

WinUI never raises this event on layout. CUIAWrapper::get_BoundingRectangle serves it on demand, and nothing in dxaml/xcp raises BoundingRectangle changes. This PR drops the per-move raise to match. RaiseAutomaticPropertyChanges on move (IsOffscreen/Name/…) is unchanged, since WinUI does the equivalent from its layout pass.

Backport of the master fix.

Measurements 📊

ItemsRepeater + UniformGridLayout, 2,837 Fluent Button tiles, 12 × 60 ChangeView steps of 40 px, Skia Win32. UI-thread time from dotnet-trace dotnet-sampled-thread-time (6.8 build, on top of the damage fix):

UI-thread accessibility UI-thread total
6.5.237 (reference) 3 ms 839 ms
before 386 ms 1,756 ms
this PR 148 ms 1,270 ms

What remains is NotifyPropertyChangedEvent from recycled TextBlock text changes, which WinUI raises as well.

PR Checklist ✅

Validation

  • Runtime (Skia Win32, local, 6.8 branch): Given_Win32Accessibility 8/8, including the new When_Element_Moves_BoundingRectangle_Is_Current, which checks that a client pulling bounds after a move gets the new position. The wider Windows_UI_Xaml_Automation run hit the known pre-existing secondary-window teardown crash (WglCurrentContextDisposable.Dispose → GetErrorMessage null); every test before that passed.
  • Compile: Uno.UI.Runtime.Skia.Win32 built without UnoFastDevBuild, so analyzers ran, on master and 6.8.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AzHtsXz33DcziPre7h3b9f

MartinZikmund and others added 2 commits September 28, 2026 14:04
Win32Accessibility raised a BoundingRectangle property-changed event for
every element whose visual moved or resized. UIA clients (PowerToys,
TextInputHost, browsers) are listening on most desktops, so every scroll
frame paid a native UIA call per realized element. WinUI never raises
this event on layout; clients pull BoundingRectangle on demand.

ItemsRepeater grid of 2837 Fluent Buttons, 12 x 60 scroll steps, UI-thread
accessibility time: 386 ms -> 148 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AzHtsXz33DcziPre7h3b9f
@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 28s —— View job


Review complete ✅

Verdict: ship — no inline findings.

  • Gather context (PR description, diff vs origin/servicing/6.8)
  • Review Win32Accessibility.cs changes
  • Review new runtime test in Given_Win32Accessibility.cs
  • Check for cross-cutting concerns (parity, event discipline, allocations)
  • Post inline findings (none needed)
  • Post summary

Summary

The change removes the per-move UiaRaiseAutomationPropertyChangedEvent(BoundingRectangle) call from Win32Accessibility.OnSizeOrOffsetChanged, leaving an empty override (required since the base SkiaAccessibilityBase declares it abstract). I verified:

  • Win32RawElementProvider.BoundingRectangle (Win32RawElementProvider.cs:447) is a computed property that pulls live bounds on each access, so the on-demand pull model the PR claims is genuinely in place — clients don't need the change event to see current bounds.
  • The unrelated automatic-property path (IsOffscreen/Name/etc. via NotifyPropertyChangedEvent/NotifyInvalidatePeer, Win32Accessibility.cs:735-788) is untouched, so the claim that "RaiseAutomaticPropertyChanges on move is unchanged" holds.
  • UIA_BoundingRectanglePropertyId and UiaRaiseAutomationPropertyChangedEvent remain used elsewhere in the file (property-changed dispatch, provider debug naming), so no dead code was left behind.
  • The new test When_Element_Moves_BoundingRectangle_Is_Current reuses the existing ResolveAccessibility/GetOrCreateProvider/GetBoundingRectangle reflection helpers and assertion tolerances consistent with sibling tests in the same file, sits under the class-level [RunsOnUIThread] + [PlatformCondition(Include, SkiaWin32)], and resets WindowHelper.WindowContent in a finally block per the runtime-tests convention.
  • This is a targeted perf fix backported from master with a red/green-style regression test guarding the on-demand pull behavior; no root-cause concerns, no async/cancellation issues, no cross-platform leakage (Win32-only file), no new public API surface.

No cross-cutting concerns beyond what's noted above.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 235988 has failed on Uno.UI - CI.

Uno.Templates@*-* now resolves to 7.0.0-dev.17, so MyApp is built on
7.0 packages and the locally built 6.x RemoteControl client never
connects. Mirrors the master ignore (37dc650).

Refs #24800

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014RHVD5sbb5nMHzf8Lu24gZ
@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 2m 11s —— View job


Review complete

Verdict: fix-first — 1 inline finding (unrelated-scope test disable), core perf fix is sound.

  • Gather context (PR description, diff vs origin/servicing/6.8)
  • Review Win32Accessibility.cs changes
  • Review new runtime test in Given_Win32Accessibility.cs
  • Review unrelated RealAppLaunchIntegrationTests.cs change
  • Check CI status
  • Post inline findings
  • Post summary

Summary

Issues by severity: 0 critical/high, 1 medium (scope/root-cause), 0 low.

The core change — dropping the per-move UiaRaiseAutomationPropertyChangedEvent(BoundingRectangle) call from Win32Accessibility.OnSizeOrOffsetChanged — is correct and well-targeted:

  • BoundingRectangle is served on demand from live bounds (matches WinUI's CUIAWrapper::get_BoundingRectangle behavior, which never raises this event from layout either).
  • The unrelated automatic-property path (IsOffscreen/Name/etc., raised from SkiaAccessibilityBase.OnScrollSourceChanged/layout routing) is untouched, consistent with the PR's claim.
  • UIA_BoundingRectanglePropertyId / UiaRaiseAutomationPropertyChangedEvent remain used elsewhere in the file, so no dead code was left behind.
  • The new runtime test reuses the existing ResolveAccessibility/GetOrCreateProvider/GetBoundingRectangle reflection helpers and tolerance conventions from sibling tests in the same file, and cleans up WindowHelper.WindowContent in a finally block per repo convention.
  • This is a backport of an already-reviewed master fix, with measurements showing a real perf win (386ms → 148ms UI-thread accessibility time in the reference scenario) and no cross-platform leakage (Win32-only file).

Cross-cutting concern (see inline comment): the third commit disables RealAppLaunchIntegrationTests.WhenRealAppBuiltAndRunWithDevServer_RealConnectionEstablished via [Ignore]. This is unrelated to the PR's stated purpose (UIA bounds perf) and appears to be an incidental CI-unblock rather than part of the accessibility fix. It's also a symptom-level fix: the root cause is that SolutionHelper always installs the newest Uno.Templates@*-* prerelease (currently 7.0), which is permanently incompatible with a servicing/6.8 build — pinning the template version would be the root-cause fix and would preserve real end-to-end DevServer connection coverage on this branch instead of disabling it indefinitely.
· branch

@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Oct 2, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants