Skip to content

Don't ever correct focus back to a UIA element that is not native or is from a window we have marked as bad UIA#11738

Merged
michaelDCurran merged 5 commits into
masterfrom
i11202
Oct 8, 2020
Merged

Don't ever correct focus back to a UIA element that is not native or is from a window we have marked as bad UIA#11738
michaelDCurran merged 5 commits into
masterfrom
i11202

Conversation

@michaelDCurran

@michaelDCurran michaelDCurran commented Oct 8, 2020

Copy link
Copy Markdown
Member

Link to issue number:

Fixes #11202
Fixes #11536
Partial fix for #11576

Summary of the issue:

NVDA can sometimes focus content in MS Edge / Chromium using UI automation, even though we have specifically disabled using UI Automation for Chrome in favor of IAccessible2.
This can happen either:

In all cases, the user may only notice that browseMode no longer works unless they tab or move focus once, but in the worse case, due to either bugs in Edge's UIA implementation or in NVDA's UIA rich text fetching code, NVDA may completely freeze. The freeze is partly why we disabled using UIA in Chromium in the first place.

In all cases, the following steps occur:

  • The object (or Window) that had focus is destroyed, but NVDA still considers it the focused object as there has not been a new focus event yet.
  • NVDA tries to locate the actual focus by asking the OS for the window with focus.
  • This window apparently natively supports UI Automation. In this case it is a "Chrome_WidgetWin_1" window.
  • In NVDAObjects.UIA.UIA.kwargsFromSuper: NVDA asks the OS for the UI Automation element with focus. In this case it gets back a link or other document content from Edge.
  • NVDA however does not bother checking if this UIA element is a usable UIA element (I.e. it is not proxied, and we have not marked its window as being bad etc).

Like with similar code that asks the OS for an object at particular hittesting coordinates, it should ensure the UIA element it gets back is usable (UIAHandler.handler.isNativeUIAElement) and if it is not, it should return False, and thus Window NVDAObject will go on and try the focus according to MSAA.

Description of how this pull request fixes the issue:

Add the needed check to NVDAObjects.UIA.UIA.kwargsFromSuper

Testing performed:

  • Logged into twitter.com in MS Edge 85 and focused a link. Put the computer to sleep and woke it up and unlocked the Windows session. Focus was restored to the link in Twitter, and it was confirmed that MSAA (not UIA) was used, by pressing NVDA+f1 and looking at the dev info.
  • Logged into twitter.com with MS Edge 85 and focused a link in the document. Pressed the applications key to bring up the context menu. Pressed escape to close the context menu. Focus went back to the link, and it was confirmed that MSAA (not UIA) was used, by looking at the dev info with NVDA+f1.

Known issues with pull request:

None.

Change log entry:

Bug fixes:

…elation of 'focus' ensure that the UIA element we get is usable (native and not a bad window etc). If it is not, return False so that other APIs can have a go instead.
Comment thread source/NVDAObjects/UIA/__init__.py Outdated
@michaelDCurran

This comment has been minimized.

@AppVeyorBot

This comment has been minimized.

LeonarddeR
LeonarddeR previously approved these changes Oct 8, 2020
@AppVeyorBot

This comment has been minimized.

feerrenrut
feerrenrut previously approved these changes Oct 8, 2020

@feerrenrut feerrenrut left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me

@michaelDCurran michaelDCurran merged commit ac31a79 into master Oct 8, 2020
@michaelDCurran michaelDCurran deleted the i11202 branch October 8, 2020 20:40
@nvaccessAuto nvaccessAuto added this to the 2020.4 milestone Oct 8, 2020
michaelDCurran pushed a commit that referenced this pull request Apr 20, 2021
…oesn't support UIA natively (#12241)

PR #11738 made it impossible to use UIA for controls which doesn't report as native UIA. This decreased accessibility of Outlook's messages list in some versions of Outlook (certainly for 2010 and possibly for 2013) which reports as non native UIA.

Description of how this pull request fixes the issue:
Similar to the fix in #11828 for these controls the fact that they're non native UIA is ignored.
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.

Problems with the new Facebook interface, Edge 85 and NVDA Edge Chromium: NVDA does not turn back to browse mode after closing the context menu

5 participants