UIA: no focus speech in a UWP XAML text control on Windows 10; GetAttributeValues faults on a null LinkAttribute

Open
#21,046 1 comment 3 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start in NVDAObjects/UIA/init.py at _getFormatFieldAtRange and inspect how it uses BulkUIATextRangeAttributeValueFetcher and UIATextRangeAttributeValueFetcher from UIAHandler/utils.py. Reproduce on Windows 10 with the reported UWP XAML control and check the bulk fetch behavior when UIA_LinkAttributeId faults. Done when focus speech completes and caret or selection reporting works for this case without breaking other text attribute retrieval.

Written by the indexing model from the issue text.

Description

needs-technical-investigation p2 triaged
Steps to reproduce
  1. On Windows 10, install Unigram 13.1 (Telegram for Windows) from the Microsoft Store and sign in.
  2. Open any chat.
  3. Press Tab until focus reaches the message box.
Actual behavior

Nothing is spoken when the message box takes focus. Typed characters are echoed, but caret movement and selection are not reported afterwards. The log shows:

ERROR - eventHandler.executeEvent (07:22:01.380) - MainThread (2620):
error executing event: gainFocus on <NVDAObjects.Dynamic_XamlEditableTextEditableTextWithAutoSelectDetectionUIA object at 0x0000018BE524E6D0> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 354, in executeEvent
  File "eventHandler.pyc", line 120, in __init__
  File "eventHandler.pyc", line 129, in next
  File "NVDAObjects\behaviors.pyc", line 338, in event_gainFocus
  File "NVDAObjects\UIA\__init__.pyc", line 1589, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1372, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1208, in reportFocus
  File "speech\speech.pyc", line 855, in speakObject
  File "speech\speech.pyc", line 922, in getObjectSpeech
  File "speech\types.pyc", line 55, in _flattenNestedSequences
  File "speech\types.pyc", line 55, in <genexpr>
  File "speech\speech.pyc", line 1595, in getTextInfoSpeech
  File "NVDAObjects\UIA\__init__.pyc", line 1033, in getTextWithFields
  File "NVDAObjects\UIA\__init__.pyc", line 1021, in _getTextWithFieldsForUIARange
  File "NVDAObjects\UIA\__init__.pyc", line 690, in _getTextWithFields_text
  File "NVDAObjects\UIA\__init__.pyc", line 412, in _getFormatFieldAtRange
  File "UIAHandler\utils.pyc", line 266, in __init__
OSError: exception: access violation reading 0x0000000000000000
Expected behavior

The edit field and its line are announced, as they are with NVDA on Windows 11 against the same app.

Analysis

The message box is a custom UWP XAML control whose text pattern is a managed ITextRangeProvider. Where a range has no link, the provider returns null for UIA_LinkAttributeId. XAML special-cases that attribute (CUIATextRangeProviderWrapper::GetAttributeValue in microsoft-ui-xaml) and hands UIA a VT_UNKNOWN whose punkVal is null.

BulkUIATextRangeAttributeValueFetcher then calls IUIAutomationTextRange3::GetAttributeValues, which on Windows 10 raises an access violation reading address 0 inside NVDA's process. ctypes surfaces it as OSError. Nothing catches it, so the whole focus announcement is lost.

From the NVDA Python console, we requested each attribute on its own through GetAttributeValues, with the caret on a line without a link. Only UIA_LinkAttributeId faulted. The rest returned normally:

Link FAILED exception: access violation reading 0x0000000000000000
AnnotationTypes None
FontName 'Segoe UI, ms-appx:///Assets/Emoji/apple.ttf#Segoe UI Emoji'
FontSize 14.0
StyleId 70012
StyleName None
Culture None
FontWeight 400
IsItalic False
HorizontalTextAlignment 0
ForegroundColor None
LineSpacing None

We did not test whether the single-attribute GetAttributeValue(UIA_LinkAttributeId) faults too.

From the XAML source, any UWP app with a managed text provider that returns no range for UIA_LinkAttributeId should hit the same fault on Windows 10. We have only seen it in Unigram.

Unigram will work around it in its next release by returning UIA's NotSupported value instead: XAML maps a NotSupportedException from the provider to it. Unigram 13.1, the current Store release, still returns the null link.

Suggestion

When GetAttributeValues raises, fall back to UIATextRangeAttributeValueFetcher. Alternatively, leave UIA_LinkAttributeId out of the bulk fetch on Windows 10. Windows 10 no longer receives fixes, so NVDA is the only place this can be handled.

System configuration
NVDA installed/portable/running from source

Installed

NVDA version

2026.2

Windows version

Windows 10 22H2, build 19045

Name and version of other software in use when reproducing the issue

A development build of Unigram, made after 13.1. We did not run the Store release itself, but its text provider returns the same null link.

Other information about your system

Windows 10 running in a virtual machine.

Other questions
Does the issue still occur after restarting your computer?

Not tried. It reproduces every time the message box takes focus.

Have you tried any other versions of NVDA? If so, please report their behaviors

No.

If NVDA add-ons are disabled, is your problem still occurring?

No add-ons installed (fresh install).

Does the issue still occur after you run the System Accessibility Repair Tool in NVDA's tools menu?

Not run.

Dominant language
Python
Stars
2.7k
Forks
842
Avg merge
2d 4h
Merged PRs (30d)
56

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nvaccess/nvda

All issues in nvaccess/nvda

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.