Skip to content

fix(a11y): Skip hidden or detached adds in the WASM semantic tree - #24383

Merged
ajpinedam merged 3 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/wasm-a11y-detached-subtree
Sep 10, 2026
Merged

ajpinedam merged 3 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/wasm-a11y-detached-subtree

Conversation

@ajpinedam

@ajpinedam ajpinedam commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #

PR Type:

🐞 Bugfix

What changed? 🚀

On Skia for WebAssembly, the accessibility bridge emitted semantic DOM nodes for controls that should not be in the tree, and those nodes carried zero geometry:

  • UIElement.AddChild raises the accessibility hook even while the subtree is still being constructed (generated XAML builds bottom-up, before the page is attached). WebAssemblyAccessibility.OnChildAdded emitted such children against the semantic root because no live ancestor could be resolved, and nothing re-parented or pruned them once the subtree attached under a Collapsed ancestor.
  • The same happened for a child added to a live parent that already sits under a Collapsed ancestor: the pruning check only inspected the child's own Visibility.

Both produced root-level 0x0 nodes (a 16x6 <button> in Chromium) for controls that are not rendered, which is what an automation or assistive-technology client then reads.

OnChildAdded now skips adds whose parent is not in the live tree and outermost adds beneath a Collapsed ancestor; the attach of the subtree root, or the ancestor being shown (pruned-handle re-emit / Visibility re-add), replays the descendants through the existing recursion. Skipped adds are Trace-logged. This mirrors the guard the macOS host already carries and the router-side drop on Skia desktop.

Visible controls were already positioned correctly; the new geometry tests pin that as a regression guard.

Behavior change

Controls hosted under a Collapsed ancestor no longer appear in the Skia-WASM accessibility tree while hidden. This is WinUI parity (Collapsed subtrees are absent from UIA) and only removes phantom zero-size nodes, but a client that relied on finding a hidden control by aria-label will now get "not found" instead of a 0x0 node.

Tests

Skia-WASM, DOM-level, Given_AccessibleGeometry: node rect matches XAML bounds for a live add and for a detached-then-attached subtree; a detached-built control lands under its named group's node; no node under a Collapsed ancestor for both orderings, and the node appears with correct bounds once the ancestor is shown. Shared helpers added to WasmSemanticDomHelper (EnsureAccessibilityEnabledAsync, GetSemanticElementRect, GetSemanticParentId).

Runtime validation (Skia-WASM, headless Edge): unfixed build 2 pass / 2 fail on the original four tests; live-tree guard alone leaves the live-Collapsed-ancestor test failing; full fix 5/5; whole Windows_UI_Xaml_Automation namespace 213 pass / 0 fail / 19 platform skips.

Not yet measured

  • Skia desktop hosts are not touched by this change (Win32 goes through AccessibilityRouter, macOS already has the equivalent guard), so they were not re-run.
  • No perf measurement; the guard is a bool read plus, for outermost adds only, an ancestor walk that replaces a JS interop call and dictionary insert per skipped element.

PR Checklist ✅

Copilot AI lite review requested due to automatic review settings September 3, 2026 16:44
@github-actions github-actions Bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform kind/documentation labels Sep 3, 2026

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.

🟡 Changes recommended

The PR description is missing a valid GitHub issue link (it currently says closes #) and must be updated to meet the repo’s mandatory issue-linking format.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes Skia-WASM accessibility-tree correctness by preventing semantic DOM nodes from being emitted for elements that are either (a) added while their subtree is still detached or (b) added under a Visibility.Collapsed ancestor—both of which previously produced “phantom” root-level nodes with zero geometry.

Changes:

  • Added an early-return guard in WebAssemblyAccessibility.OnChildAdded to skip detached and collapsed-ancestor adds, plus a helper to detect collapsed ancestry.
  • Added new Skia-WASM DOM-level runtime tests (Given_AccessibleGeometry) to pin correct semantic-node placement, parenting, and collapsed-subtree pruning behavior.
  • Expanded WasmSemanticDomHelper with shared helpers for enabling accessibility, querying semantic-node rects, and parent DOM ids; updated the remediation tasks spec with the follow-up note.

Note: The PR description currently includes **GitHub Issue:** closes # (blank). This repo requires either a real issue link or an explicit “no public issue” note in the required format.

File summaries
File Description
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/WasmSemanticDomHelper.cs Adds shared DOM-query helpers and an async “ensure a11y enabled” helper to stabilize dynamic-path semantic DOM tests.
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_AccessibleGeometry.cs New Skia-WASM runtime tests validating semantic DOM geometry/parenting and collapsed-subtree absence until shown.
src/Uno.UI.Runtime.Skia.WebAssembly.Browser/Accessibility/WebAssemblyAccessibility.cs Skips OnChildAdded processing for detached parents and outermost adds under collapsed ancestors; adds collapsed-ancestor detection helper.
specs/003-wasm-a11y-remediation/tasks.md Updates task T058 with the runtime-found ordering edge case and test coverage note.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 231933 found UI Test snapshots differences: skia-linux-screenshots: 57, skia-windows-screenshots: 2310, wasm: 11

Details
  • skia-linux-screenshots: 57 changed over 2348

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • DropDownButtonPage.png-dark
    • DropDownButtonPage.png
    • Examples.png-dark
    • Examples.png
    • ExpanderColorValidationPage.png-dark
    • ExpanderColorValidationPage.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ContextRequested.png-dark
    • ContextRequested.png
    • Gamepad_CurrentReading.png-dark
    • Gamepad_CurrentReading.png
    • Gamepad_Enumeration.png-dark
    • Gamepad_Enumeration.png
    • Buttons.png-dark
    • Buttons.png
    • Focus_FocusVisual_Properties.png-dark
    • ElementLevelTheme.png-dark
  • skia-windows-screenshots: 2310 changed over 2402

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AppBarToggleButtonTest.png-dark
    • Accessibility_ScreenReader.png-dark
    • ArcSegment.png-dark
    • Attributed_text_FontSize_Changing.png-dark
    • AutoBorderStretchwithrightmargin.png-dark
    • AutomationProperties_Name.png
    • AutoSizedTopLeft.png-dark
    • AutoSuggestBox_SoftKeboard.png-dark
    • AutoSuggestBox_Reason.png
    • BasicThemeResources.png-dark
    • BasicThemeResources.png
    • BitmapIcon_Monochromatic.png-dark
    • BitmapImage_vs_SvgImageSource.png-dark
    • BorderCenteredwithmargins.png
    • BorderLeftwithmargins.png-dark
    • BorderLeftwithmargins.png
    • BorderWithNullBrushAndNonZeroThickness.png-dark
    • Border_AntiAlias.png-dark
    • BorderWithNullBrushAndNonZeroThickness.png
    • Border_AntiAlias.png
  • wasm: 11 changed over 1076

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Ogg_Extension
    • UITests.Shared.Microsoft_UI_Xaml_Controls.ExpanderTests.WinUIExpanderPage
    • UITests.Shared.Windows_UI_Xaml_Controls.MediaPlayerElement.MediaPlayerElement_Minimal
    • UITests.Windows_UI_Xaml_Controls.CalendarView.CalendarView_Theming
    • SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_EnableDevTools
    • UITests.Uno_Web.Http.CookieManagerTests
    • UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigationProperties
    • UITests.Windows_UI_Xaml_Media_Animation.ColorAnimation_Background
    • SamplesApp.Wasm.Windows_UI_Xaml_Controls.ListView.ListView_IsSelected
    • SamplesApp.Windows_UI_Xaml_Controls.ListView.ListViewSelectedItems
    • Uno.UI.Samples.Content.UITests.WebView.WebView_AnchorNavigation

@unodevops

Copy link
Copy Markdown
Contributor

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

@ajpinedam

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport servicing/6.8

@mergify

mergify Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

backport servicing/6.8

✅ Backports have been created

Details

@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.

Skipping detached additions and pruning beneath a collapsed ancestor is consistent with WinUI's ChildIsAcceptable visibility gate and recursive child walk. The change does not equate offscreen/zero-size/transparent content with Collapsed. Existing subtree attach and pruned-handle reveal paths supply the deferred emission, and the new cases exercise both ordering variants, geometry and semantic parenting. No blocking source-level discrepancy found.

@mergify

mergify Bot commented Sep 9, 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.

@ajpinedam
ajpinedam merged commit ee8ffda into unoplatform:master Sep 10, 2026
49 checks passed
@ajpinedam
ajpinedam deleted the dev/anpi/wasm-a11y-detached-subtree branch September 10, 2026 12:28
agneszitte added a commit that referenced this pull request Sep 11, 2026
…r-24383

fix(a11y): Skip hidden or detached adds in the WASM semantic tree (backport #24383)
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/6.7

@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/6.7

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Oct 27, 2026
…6.7/pr-24383

fix(a11y): Skip hidden or detached adds in the WASM semantic tree (backport #24383)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/documentation platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants