Skip to content

perf(win32): Stop raising UIA bounds changes on layout (6.7) - #24787

Merged
agneszitte merged 4 commits into
release/stable/6.7from
dev/mazi/67-win32-uia-bounds
Oct 28, 2026
Merged

agneszitte merged 4 commits into
release/stable/6.7from
dev/mazi/67-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. 6.7 ships the same Win32Accessibility path.

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

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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


Review

  • Gather context (PR description, changed files)
  • Read Win32Accessibility.cs changes
  • Read Given_Win32Accessibility.cs test changes
  • Review diff against origin/release/stable/6.7
  • Post inline comments for findings
  • Post summary

Verdict: ✅ Approve (1 nit)

1 minor inline finding · 0 blockers

Cross-cutting notes

Implementation correctness — LGTM. The empty OnSizeOrOffsetChanged override is correct. The call chain in SkiaAccessibilityBase.RouteVisualOffsetOrSizeChanged (line 234) invokes OnSizeOrOffsetChanged and then, independently on line 243, calls CachedAutomationPeer?.RaiseAutomaticPropertyChanges. So dropping the BoundingRectangle raise from the override leaves IsOffscreen/Name/ItemStatus notifications fully intact — exactly what the PR description asserts.

WinUI parity — LGTM. OnSizeOrOffsetChanged is abstract in the base; Win32 being the only platform making it a no-op is correct. No other platform override is affected.

Test — LGTM. When_Element_Moves_BoundingRectangle_Is_Current correctly exercises the pull-on-demand contract: it mutates the margin, waits for idle, and asserts that BoundingRectangle reflects the new position without relying on a push event. Math (Δleft = 60 logical px, Δtop = 40 logical px, tolerance 2 × scale) is correct. One nit posted inline: missing [GitHubWorkItem] for traceability to issue #24784.

@unodevops

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 29s —— View job


Review

  • Gather context (PR description, changed files)
  • Read changed files and check if previous nit was addressed
  • Review new commit (5d2e8789)
  • Post summary

Verdict: ✅ Approve (1 outstanding nit from prior review)

New commit (5d2e8789) — LGTM

Adds [Ignore(...)] to WhenRealAppBuiltAndRunWithDevServer_RealConnectionEstablished in RealAppLaunchIntegrationTests.cs. The reason is accurate and self-contained: Uno.Templates@*-* resolves to 7.0 prereleases on this branch, so the 6.x RemoteControl client can't connect. The two-line code comment above is slightly redundant with the [Ignore] message, but it's harmless and follows the pattern on master (37dc6504919).

Outstanding nit (unfixed since prior review)

The [GitHubWorkItem("https://github.com/unoplatform/uno/issues/24784")] attribute is still missing on When_Element_Moves_BoundingRectangle_Is_Current (Given_Win32Accessibility.cs:331). The inline comment from the prior review stands — no new inline posted.

Cross-cutting (unchanged from prior review)

Win32Accessibility.OnSizeOrOffsetChanged — empty override, comment explains WinUI parity rationale, RaiseAutomaticPropertyChanges path is unaffected. Test math (Δleft = 60 px, Δtop = 40 px) is correct. No new issues found.

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI balanced review requested due to automatic review settings October 2, 2026 05:47
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Claude Code is working…

I'll analyze this and get back to you.

View job run

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The regression is not directly tested, and an unrelated end-to-end test is disabled.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Removes costly Win32 UIA BoundingRectangle notifications during layout to match WinUI behavior.

Changes:

  • Makes Win32 layout-bound notifications a no-op.
  • Adds an on-demand bounds test.
  • Disables an unrelated DevServer integration test.
File Description
Given_Win32Accessibility.cs Tests bounds after movement.
Win32Accessibility.cs Stops layout-time bounds notifications.
RealAppLaunchIntegrationTests.cs Ignores incompatible integration test.

Comment on lines +19 to +22
// Uno.Templates@*-* resolves to 7.0 prereleases, so MyApp is built on 7.0 packages and the
// locally built 6.x RemoteControl client never connects (no app-launch/connected event).
[TestMethod]
[Ignore("Uno.Templates@*-* scaffolds MyApp against 7.0 packages, which this 6.x build cannot connect to.")]
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

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

MartinZikmund and others added 4 commits October 3, 2026 10:51
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
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
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/67-win32-uia-bounds branch from 14ce795 to ac87340 Compare October 3, 2026 08:51
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 1m 56s —— View job


Review

  • Gather context (PR description, prior reviews, changed files)
  • Read changed files
  • Assess Copilot findings and prior nit resolution
  • Post inline comments
  • Post summary

Verdict: ✅ Approve — 0 new findings

Prior nit — resolved

[GitHubWorkItem("https://github.com/unoplatform/uno/issues/24784")] is now on When_Element_Moves_BoundingRectangle_Is_Current (line 331). That finding is closed.

Copilot findings — addressed

"Test does not verify BoundingRectangle events are suppressed" — Technically accurate, but intercepting COM-level UIA property-change events from a test process requires a real out-of-process UIA client. No such infrastructure exists in Uno.UI.RuntimeTests. The test verifies the pull-on-demand contract that clients actually depend on, and the comment at line 329 documents the WinUI parity rationale explicitly. Not blocking.

"Do not disable app-to-DevServer integration coverage" — The [Ignore] is the right call for this backport branch. Uno.Templates@*-* resolves to 7.0 pre-releases; pinning a 6.x-compatible template version is a cross-repo coordination problem that is out of scope for a perf fix backport. The [Ignore] message documents the root cause clearly. Copilot's suggested fix (changing SolutionHelper.cs:94) would be a larger structural change; nothing in this PR prevents it being done separately.

Cross-cutting — LGTM

  • Implementation: empty OnSizeOrOffsetChanged override is correct. The adjacent RaiseAutomaticPropertyChanges call (via SkiaAccessibilityBase.RouteVisualOffsetOrSizeChanged) is unaffected, so IsOffscreen/Name/ItemStatus notifications remain live.
  • WinUI parity: WinUI does not raise BoundingRectangle on layout; this override brings Uno in line.
  • Test hygiene: [RunsOnUIThread] at class level covers the new test; UITestHelper.Load + WaitForIdle sequencing is correct; finally resets WindowHelper.WindowContent. Math (Δleft = 60 px, Δtop = 40 px, tolerance 2×scale) is correct.
  • Code style: tab indentation, Allman braces, comment explains the non-obvious why without narrating the what. No issues.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

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

@morning4coffe-dev morning4coffe-dev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: the change matches master #24785 in behavior. Win32Accessibility.OnSizeOrOffsetChanged no longer raises a UIA BoundingRectangle property change on layout, and the other heads are untouched. WinUI does not raise BoundingRectangle changes on layout (clients pull it on demand), so this is WinUI-consistent. The new runtime test's helpers (ResolveAccessibility, GetOrCreateProvider, GetBoundingRectangle) exist in the 6.7 test file.

Findings:

  1. Undisclosed test disable (blocking for merge as written). src/Uno.UI.RemoteControl.DevServer.Tests/AppLaunch/RealAppLaunchIntegrationTests.cs gains [Ignore("Uno.Templates@*-* scaffolds MyApp against 7.0 packages, ...")]. That is unrelated to UIA bounds and the PR body does not mention it. Please either move it to its own PR or add a line to the body explaining why the test is off on 6.7 and what re-enables it. Note that master's copy of the same test carries a different [Ignore] reason, so the branches disagree on why it is disabled.
  2. Structural difference, no behavior impact: master #24785 makes SkiaAccessibilityBase.OnSizeOrOffsetChanged virtual with an empty default and drops the Win32 override. This 6.7 port keeps the base abstract and adds an empty Win32 override with an unused parameter. Acceptable for 6.7; no change needed.

Validation: code review and WinUI source check only. I did not build or run tests. The PR body's runtime results come from the 6.8 backport (#24786), not from this 6.7 branch.

@agneszitte
agneszitte merged commit 1610d2c into release/stable/6.7 Oct 28, 2026
62 of 65 checks passed
@agneszitte
agneszitte deleted the dev/mazi/67-win32-uia-bounds branch October 28, 2026 01:37
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.

6 participants