perf(macos): build the accessibility tree when a client first asks for it - #25028
Open
ramezgerges wants to merge 1 commit into
Open
ramezgerges wants to merge 1 commit into
ramezgerges wants to merge 1 commit into
Conversation
…r it The macOS accessibility bridge built the native tree for every window at startup and kept it in sync on every change, including two native calls and an ancestor walk for every moved or resized visual, whether or not any accessibility client was running. The window now asks managed code to build the tree the first time a client queries its children, focused element or hit test; until then the bridge stays idle. The first query already sees the tree, which is built synchronously before the native side answers. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-25028/wasm-skia-net9/index.html |
Contributor
|
The build 237489 found UI Test snapshots differences: Details
|
MartinZikmund
approved these changes
Oct 5, 2026
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
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: closes #25027
PR Type:
🔄 Refactoring (performance; no API changes)
What changed? 🚀
On macOS, a window's native accessibility tree is now built the first time an accessibility client queries the window, instead of at startup. Until then the bridge stays idle.
UnoNativeMac): the window'saccessibilityChildren,accessibilityFocusedUIElementandaccessibilityHitTestfirst calluno_accessibility_ensure_tree. The first time, that invokes a new "tree requested" callback; atreeRequestedflag on the per-window context makes it once per window. These are the entry points every client uses first: VoiceOver, Switch Control, Accessibility Inspector, UI automation.MacOSAccessibility):IsAccessibilityEnabledis false until a client has asked. All existing guards in the bridge and inSkiaAccessibilityBasetherefore skip their work: no tree, nouno_accessibility_update_frameor_visibilityper moved visual, no structure notifications. The callback marks the window as requested and builds the tree synchronously, so the client's first query already gets the root element. The host provides the root element throughRootElementProvider.Once built, the tree is kept up to date as before.
Measurements
Apple M2, macOS 15.7.1, Skia desktop, Release, fully optimized (
DOTNET_TieredCompilation=0). This uses thePerf_TreeGridParitysample from #24972: a virtualizing 10,000 × 64 text grid, timed as the operation plusUpdateLayout. Builds were interleaved over 3 rounds, swapping onlyUno.UI.Runtime.Skia.MacOS.dllandlibUnoNativeMac.dylib. "Bridge disabled" skips creating the bridge at all and is shown as the floor.The "Accessibility tree initialized" log line appears in every run before this change and in none after it, since no client was running.
Tests
Given_MacOSAccessibilityOnDemand.When_No_Client_Queried_Then_Tree_Is_Built_On_First_Query. A new window's bridge is idle: not enabled, no tree. SendingaccessibilityChildrento itsNSWindow, as a client would, enables it, builds the tree, and already returns the root element.Given_MultiWindowAccessibilityasserted that each window's accessibility is enabled from the start. On macOS it now makes the same client query first (a no-op on Win32).Windows_UI_Xaml_Automationruntime tests pass; the 102 skipped are for other platforms.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code