Skip to content

LoopingSelectorItemAutomationPeer is constructed without its owner, throwing NullReferenceException for every picker item #24183

Closed

Description

@MartinZikmund

Current behavior 🐛

LoopingSelectorItemAutomationPeer never passes its owner to the base peer, so every instance has a
null Owner and throws NullReferenceException the moment the accessibility layer asks it anything.

src/Uno.UI/UI/Xaml/Controls/Primitives/LoopingSelector/LoopingSelectorItemAutomationPeer_Partial.cs:

internal LoopingSelectorItemAutomationPeer(LoopingSelectorItem pOwner)
{
    InitializeImpl(pOwner);
}

There is no : base(pOwner), so the parameterless FrameworkElementAutomationPeer() runs. In the
ported C++ the owner was wired up by the CreateInstanceWithOwner block that is commented out
immediately below. Its sibling in the same folder does it correctly:

internal LoopingSelectorAutomationPeer(LoopingSelector pOwner) : base(pOwner)

On the macOS Skia host this is loud, because MacOSAccessibility resolves a role and applies
attributes for every element entering the tree, catches the exception, and logs it twice. From build
229772 (Run macOS Runtime Tests, 8116 tests, 45 546 log lines):

line count
[A11y] Failed to resolve role for LoopingSelectorItem handle=…: Object reference not set to an instance of an object. 2879
Failed to apply accessibility attributes for …LoopingSelectorItem: Object reference not set to an instance of an object. 2879
Failed to apply accessibility attributes for …ComboBox: Object reference not set to an instance of an object. 498

That is 6256 lines, ~14 % of the entire macOS CI log, from one missing base call. Attributed by
the test running at the time, it concentrates in the pickers:

test lines
When_Time_Zone() 3306
When_Fast_Scrolling_Items_Should_Remain_Visible() 616
When_MonochromaticOverlayPresenter_Workaround() 194

The functional consequence is that LoopingSelectorItem — every row of a TimePicker or
DatePicker flyout — exposes no role and no attributes to VoiceOver at all.

Expected behavior 🎯

LoopingSelectorItemAutomationPeer is constructed with its owner, resolves a role
(GetAutomationControlTypeCore already returns AutomationControlType.ListItem), and reports
attributes to the platform accessibility layer without throwing.

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

Run any TimePicker/DatePicker runtime test on the macOS Skia head with debug logging on, e.g.
Given_TimePickerFlyout.When_Time_Zone, and watch for [A11y] Failed to resolve role for LoopingSelectorItem. It is also visible in any macOS CI log; logs are readable anonymously:

https://dev.azure.com/uno-platform/1dd81cbd-cb35-41de-a570-b0df3571a196/_apis/build/builds/229772/logs/505

Workaround 🛠️

None. The exception is caught, so it degrades to "no accessibility for picker items" plus log noise.

Renderer 🎨

Skia

Affected platforms 📱💻🖥️

The peer defect is platform-independent (Uno.UI). It is observed on Skia Desktop (macOS), whose
accessibility layer resolves roles eagerly; any host that queries this peer will hit the same
NullReferenceException.

Uno.Sdk version (and other relevant versions) 📦

Present on feature/breakingchanges; the constructor has been in this shape since the LoopingSelector
port.

IDE version 🧑‍💻

N/A

Anything else we need to know? 💬

Found while measuring the macOS runtime-test job for #24005. It is not a cause of the freezes tracked
there — the cost is exception throw/catch plus console I/O — but it is the single largest source of
noise in the macOS log, and it is a real accessibility gap for picker items rather than only a
logging problem.

Two adjacent observations, deliberately not folded in here:

  • MacOSAccessibility.IsAccessibilityEnabled is !IsDisposed && _windowHandle != nint.Zero, i.e.
    always true once a window exists, so the whole visual tree is mirrored into native accessibility
    elements whether or not any assistive technology is running. Win32Accessibility has the same
    shape; WebAssemblyAccessibility gates on an actual _isAccessibilityEnabled flag. Whether the
    desktop hosts should gate too is worth its own discussion.
  • The 498 ComboBox failures above are a separate null-reference path in the same code, not
    investigated here.

Activity

  1. added
    triage/untriaged
    on Aug 24, 2026
  2. MartinZikmund commented on Oct 1, 2026

    @MartinZikmund
    MemberAuthor

    Additional data point: the same missing : base(pOwner) also breaks the WebAssembly Skia accessibility layer, via a different member.

    On WASM Skia CI runtime tests, WebAssemblyAccessibility.OnChildAdded logs this for every LoopingSelectorItem (hundreds per shard), and the item is dropped from the accessibility tree:

    [A11y] OnChildAdded failed for LoopingSelectorItem: Object reference not set to an instance of an object.
    System.NullReferenceException
       at Microsoft.UI.Xaml.Automation.Peers.FrameworkElementAutomationPeer.GetHeadingLevelCore()
       at Uno.UI.Runtime.Skia.AriaMapper.GetSemanticElementType(AutomationPeer peer, UIElement owner)
       at Uno.UI.Runtime.Skia.WebAssemblyAccessibility.AddSemanticElement(...)
    

    So the user-visible effect on WASM is that TimePicker/DatePicker flyout items are absent from the accessible tree.

    Still present on current master (checked by code inspection: the constructor in LoopingSelectorItemAutomationPeer_Partial.cs has no : base(pOwner)).

    Suggested fix, two parts:

    1. Add : base(pOwner) to the constructor.
    2. FrameworkElementAutomationPeer.GetHeadingLevelCore() is => AutomationProperties.GetHeadingLevel(Owner); with no null guard, unlike e.g. GetAcceleratorKeyCore. Guarding it would make a mis-constructed peer degrade instead of throw.

    A runtime test could open a TimePicker flyout and assert that the LoopingSelectorItem peers have a non-null Owner (and that GetHeadingLevel() doesn't throw).

  3. added
    7.0
    on Oct 14, 2026
  4. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
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