Hi,
Discovered while debugging modern keyboard support in 20H2:
Steps to reproduce:
With NVDA set to debug logging, do:
- Open emoji panel (Windows+period).
- Press Tab to move to emoji group.
- Press right arrow a couple times to move to a different group and press Enter to select it.
Actual behavior:
The following traceback pair is recorded:
DEBUGWARNING - UIAHandler.UIAHandler.IUIAutomationEventHandler_HandleAutomationEvent (12:48:58.162) - Dummy-3 (11912):
HandleAutomationEvent: Exception while creating object for event stateChange
Traceback (most recent call last):
File "UIAHandler.pyc", line 464, in IUIAutomationEventHandler_HandleAutomationEvent
File "NVDAObjects_init.pyc", line 86, in call
File "NVDAObjects\UIA_init.pyc", line 890, in findOverlayClasses
File "comtypes_init_.pyc", line 279, in getattr
File "comtypesMonkeyPatches.pyc", line 26, in call
ctypes.COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))
DEBUGWARNING - UIAHandler.UIAHandler.IUIAutomationEventHandler_HandleAutomationEvent (12:48:58.166) - Dummy-3 (11912):
HandleAutomationEvent: Exception while creating object for event UIA_elementSelected
Traceback (most recent call last):
File "UIAHandler.pyc", line 464, in IUIAutomationEventHandler_HandleAutomationEvent
File "NVDAObjects_init.pyc", line 86, in call
File "NVDAObjects\UIA_init.pyc", line 890, in findOverlayClasses
File "comtypes_init.pyc", line 279, in getattr
File "comtypesMonkeyPatches.pyc", line 26, in call
_ctypes.COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))
Expected behavior:
UIA objects are constructed so that events can be handled.
System configuration
NVDA installed/portable/running from source:
Installed
NVDA version:
alpha-20656,87eee7f4
Windows version:
Windows 10 Version 20H2 beta (build 19042.423)
Name and version of other software in use when reproducing the issue:
None
Other information about your system:
Used to develop add-ons such as Windows 10 App Essentials
Other questions
Does the issue still occur after restarting your computer?
Yes
Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes - occurs in older versions such as 2020.1.
If addons are disabled, is your problem still occurring?
Yes
Did you try to run the COM registry fixing tool in NVDA menu / tools?
Not applicable
Cause:
The tracebacks above are seen when an exception occurs when trying to obtain automation ID. The part where UIA object's findOverlayClasses is invoked comes from DevExpress fix (issue #10918). A related issue exists when NVDA fails to locate UIA search fieldds.
Possible solutions:
- Let find overlay classes method raise an exception and return early if an exception occurs while trying to obtain automation ID. This also allows a local variable to record automation ID, saving NVDA from having to hunt this through attribute access throughout the method.
- Assign a placeholder when an exception occurs when obtaining automation ID. Because automation ID is a string, it should be assigned to a string value (say, an empty string). At the same time, log the fact that automation ID could not be located.
- Wrap individual overlay class conditions involving automation ID inside a try statement. This is perhaps the least disruptive solution, although this will mean future pull requests involving UIA object's find overlay classes method must be careful to do this whenever automation ID is consulted.
- Unless the specs say otherwise, from UIA handler thread's event handlers, do not instantiate UIA objects if an exception occurs when fetching automation ID. This is perhaps the most optimized solution, as it saves NVDA from going through routines to instantiate overlay classes just to handle an event.
- Find a way to talk to UIAutomationCore.dll or the UIA element in question to determine conditions where fetching automation ID's might produce exceptions. This will involve looking at apps where automation ID fetch exception is pronounced (such as modern keyboard) so a workaround can be developed (including the strategies listed above).
- Add a dedicated automation ID property to UIA objects (idea came from @LeonarddeR). This allows errors to be logged if any ans simplifies many code paths where automation ID check is involved (such as find overlay classes, add-ons, and UIA objects scattered throughout NVDA).
Thanks.
Hi,
Discovered while debugging modern keyboard support in 20H2:
Steps to reproduce:
With NVDA set to debug logging, do:
Actual behavior:
The following traceback pair is recorded:
DEBUGWARNING - UIAHandler.UIAHandler.IUIAutomationEventHandler_HandleAutomationEvent (12:48:58.162) - Dummy-3 (11912):
HandleAutomationEvent: Exception while creating object for event stateChange
Traceback (most recent call last):
File "UIAHandler.pyc", line 464, in IUIAutomationEventHandler_HandleAutomationEvent
File "NVDAObjects_init.pyc", line 86, in call
File "NVDAObjects\UIA_init.pyc", line 890, in findOverlayClasses
File "comtypes_init_.pyc", line 279, in getattr
File "comtypesMonkeyPatches.pyc", line 26, in call
ctypes.COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))
DEBUGWARNING - UIAHandler.UIAHandler.IUIAutomationEventHandler_HandleAutomationEvent (12:48:58.166) - Dummy-3 (11912):
HandleAutomationEvent: Exception while creating object for event UIA_elementSelected
Traceback (most recent call last):
File "UIAHandler.pyc", line 464, in IUIAutomationEventHandler_HandleAutomationEvent
File "NVDAObjects_init.pyc", line 86, in call
File "NVDAObjects\UIA_init.pyc", line 890, in findOverlayClasses
File "comtypes_init.pyc", line 279, in getattr
File "comtypesMonkeyPatches.pyc", line 26, in call
_ctypes.COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))
Expected behavior:
UIA objects are constructed so that events can be handled.
System configuration
NVDA installed/portable/running from source:
Installed
NVDA version:
alpha-20656,87eee7f4
Windows version:
Windows 10 Version 20H2 beta (build 19042.423)
Name and version of other software in use when reproducing the issue:
None
Other information about your system:
Used to develop add-ons such as Windows 10 App Essentials
Other questions
Does the issue still occur after restarting your computer?
Yes
Have you tried any other versions of NVDA? If so, please report their behaviors.
Yes - occurs in older versions such as 2020.1.
If addons are disabled, is your problem still occurring?
Yes
Did you try to run the COM registry fixing tool in NVDA menu / tools?
Not applicable
Cause:
The tracebacks above are seen when an exception occurs when trying to obtain automation ID. The part where UIA object's findOverlayClasses is invoked comes from DevExpress fix (issue #10918). A related issue exists when NVDA fails to locate UIA search fieldds.
Possible solutions:
Thanks.