Skip to content

[Skia/macOS] An element added later under a Raw parent replaces the window's accessibility root #26708

Backlog

Description

@michaelstonis

Current behavior 🐛

On the Skia macOS host, an element added to the visual tree after the accessibility tree is built, under a parent whose AutomationProperties.AccessibilityView is Raw, replaces the window's accessibility root. VoiceOver and Accessibility Inspector are then left with one stray element (for example a 1×1 template part); every other control in the window disappears from the tree.

Cause, as of 7.0.65:

  • MacOSAccessibility.OnChildAdded(parent, child, index) skips a Raw child and recurses into its children, but it does not check whether the parent is Raw. It calls AddAccessibilityElement(parent.Visual.Handle, child, index) with the handle of the Raw parent, which was never registered with the native side (BuildAccessibilityTreeRecursive attaches a Raw element's children to the nearest registered ancestor instead).
  • uno_accessibility_add_element (UNOAccessibility.m) does not find that parent handle, so parent is nil and it takes the else branch: context.rootElement = element;. The new child becomes the root of the window's tree.

Any template that builds Raw parts on first layout triggers it on pages shown after the first one: a TextBox's ContentElement scroll viewer, a ScrollBar thumb, a ToggleSwitch thumb, a TextBox marked Raw by the app. In a Debug build with UseStudio(), Hot Design's elements do the same at launch, so the tree is empty from the start.

Expected behavior 🎯

A child added under a Raw parent attaches to the nearest registered ancestor, as it does during the initial build, and the native side never replaces the root with an element whose parent handle it does not know (log and drop, or attach to the window's root instead).

How to reproduce it (as minimally and precisely as possible)

Seen in a Skia app whose later pages host a canvas-drawn control with a hidden Raw TextBox child, and pages with ScrollBars and ToggleSwitches. These are the minimal steps that follow from the code above (not yet tried as a standalone repro):

  1. Uno.Sdk 7.0.22 (Uno.WinUI 7.0.65), net10.0-desktop, macOS, Release build.
  2. A window with a Frame and two pages. The second page contains a Button and a TextBox with AutomationProperties.AccessibilityView="Raw" (or any ScrollBar).
  3. Turn VoiceOver on, launch, navigate to the second page.
  4. VoiceOver (or Accessibility Inspector) shows a single element: the TextBox template part (or the thumb). The Button and the rest of the window are gone. Navigating back does not restore them.

The first page shown at launch is exposed correctly.

Workaround 🛠️

None found in app code. Applying the templates earlier does not help: the template parts are still added once the element is in the window.

Works on UWP/WinUI 🤷

Yes

Affected platforms 📱💻🖥️

Skia (macOS)

Uno.Sdk version (and other relevant versions) 📦

Uno.Sdk 7.0.22 / Uno.WinUI 7.0.65 (first seen on 6.7.135), .NET 10, macOS 26.

Anything else we need to know? 💬

Possibly related: #25228 (a closed context flyout removes the control from the macOS tree) and #24669.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions