Skip to content

UIAHandler: instruct UIA client library to never map winEvents to UIA propertyChange events.#8785

Merged
michaelDCurran merged 3 commits into
masterfrom
unregisterUIAProxyWinEvents
Sep 26, 2018
Merged

UIAHandler: instruct UIA client library to never map winEvents to UIA propertyChange events.#8785
michaelDCurran merged 3 commits into
masterfrom
unregisterUIAProxyWinEvents

Conversation

@michaelDCurran

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #7345

Summary of the issue:

Sometimes UI Automation focus events stop firing across the Operating System, if a background app is currently firing a lot of MSAA events and at the same time is slow to respond to window messages. An example would be trying to use File Explorer while another app is showing a progress bar while processing audio.

It was identified that the problems stemmed from UI automation's automatic proxying of MSAA. If an app fired an MSAA winEvent, but then was slow to respond to the WM_GETOBJECT message sent by UI Automation core in order to fetch the MSAA object for proxying to UI Automation, UI Automation core would fail to fire any future focus change events across the entire Operating System.

PR #8742 tried to address this by only registering for UIA property change events for the foreground and its descendants, rather than globally at NVDA launch. However, this caused crashes in File Explorer on recent versions of Windows 10.

Description of how this pull request fixes the issue:

NVDA itself has no use for proxied MSAA objects, as it has its own native support for MSAA, and always uses that if a window does not natively support UI Automation.

However, removing the MSAA proxy all together has the disadvantage of changing the topology of the UI Automation element tree, and in some rare cases, NVDA may still make use of a proxied MSAA object for perhaps a window says its native UI Automation but its implementation is incomplete. (E.g. the tab control in the Windows 10 task manager).

Although we can't remove the proxy all together, we can at least stop the proxy from proxying MSAA winEvents to UI Automation property change events. NVDA never has any use for these property change events as it listens to MSAA winEvents natively.

Therefore, this PR walks through all the registered proxies, and unmaps any MSAA winEvents for the UI Automation property change events NVDA listens to.

Testing performed:

  • Testing on Windows 10 has shown that it does not cause the File Explorer crash reported from pr Per foreground uia property change events #8742.
  • Testing shows that UI automation focus events continue to fire correctly if an application is firing winEvents but is slow to respond, such as winSCP or windbg Open crash dump dialog.

Known issues with pull request:

None known.

Change log entry:

Bug fixes:
NVDA no longer fails to track focus in File Explorer and other applications using UI Automation when another app is busy (such as batch processing audio). (#7345)

LeonarddeR
LeonarddeR previously approved these changes Sep 26, 2018

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks fine to me.

Comment thread source/_UIAHandler.py
isUIA8=True
except (COMError,WindowsError,NameError):
self.clientObject=CoCreateInstance(CUIAutomation._reg_clsid_,interface=IUIAutomation,clsctx=CLSCTX_INPROC_SERVER)
# #7345: Instruct UIA to never map MSAA winEvents to UIA propertyChange events.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I"m still an advocate of making this configurable with a hidden config parameter, i.e. config.conf['UIA']['unregisterProxyWinEvents']

Comment thread source/_UIAHandler.py
# #7345: Instruct UIA to never map MSAA winEvents to UIA propertyChange events.
# These events are not needed by NVDA, and they can cause the UI Automation client library to become unresponsive if an application firing winEvents has a slow message pump.
pfm=self.clientObject.proxyFactoryMapping
for index in xrange(pfm.count):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the amount of entries in a mapping stable, or can it change while NVDA is running (i.e. can new entries be added for which unregistration has to take place)?

@michaelDCurran

michaelDCurran commented Sep 26, 2018 via email

Copy link
Copy Markdown
Member Author

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UIA seems to stall under certain conditions.

3 participants