Repository: nvaccess/nvda

Issue:
Problems with the new Facebook interface, Edge 85 and NVDA
Issue reported by an Spanish-speaking user through Twitter, reproduced by another different user (@carlos-estebanM). All the below information is according to original user's comments, as I have been unable to test this as I don't have a active Facebook account with friends to chat with.

### Steps to reproduce

1. Open Edge. Chrome and Firefox are working fine with this.
2. Switch to the new Facebook desktop interface (not the usual one).
3. Enter a chat.
4. Press any "Message Actions" button, that is supposed to show a dropdown menu.

### Actual behavior:

NVDA core freezes throwing an exception to the log. Message actions dropdown is not accessible after NVDA auto-recovery. Could be related to #10895.
ERROR - eventHandler.executeEvent (15:04:44.730) - MainThread (12848):
error executing event: gainFocus on with extra args of {}
Traceback (most recent call last):
File "speech\__init__.pyc", line 523, in getObjectSpeech
File "documentBase.pyc", line 24, in makeTextInfo
File "NVDAObjects\UIA\__init__.pyc", line 308, in __init__
NotImplementedError: UIAutomationTextRangeArray is empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "eventHandler.pyc", line 214, in executeEvent
File "eventHandler.pyc", line 94, in __init__
File "eventHandler.pyc", line 102, in next
File "C:\Users\USUARIO\AppData\Roaming\nvda\addons\remote\globalPlugins\remoteClient\__init__.py", line 426, in event_gainFocus
nextHandler()
File "eventHandler.pyc", line 102, in next
File "NVDAObjects\behaviors.pyc", line 185, in event_gainFocus
File "NVDAObjects\__init__.pyc", line 1105, in event_gainFocus
File "NVDAObjects\__init__.pyc", line 991, in reportFocus
File "speech\__init__.pyc", line 478, in speakObject
File "speech\__init__.pyc", line 548, in getObjectSpeech
File "speech\types.pyc", line 50, in _flattenNestedSequences
File "speech\types.pyc", line 50, in 
File "speech\__init__.pyc", line 1127, in getTextInfoSpeech
File "NVDAObjects\UIA\__init__.pyc", line 715, in getTextWithFields
File "NVDAObjects\UIA\__init__.pyc", line 685, in _getTextWithFieldsForUIARange
File "NVDAObjects\UIA\__init__.pyc", line 685, in _getTextWithFieldsForUIARange
File "NVDAObjects\UIA\__init__.pyc", line 685, in _getTextWithFieldsForUIARange
[Previous line repeated 42 more times]
File "NVDAObjects\UIA\__init__.pyc", line 663, in _getTextWithFieldsForUIARange
File "comtypesMonkeyPatches.pyc", line 26, in __call__
_ctypes.COMError: (-2147417851, 'El servidor lanzó una excepción.', (None, None, None, 0, None))
WARNING - watchdog._watcher (15:04:50.354) - watchdog (9580):
Core frozen in stack:
File "nvda.pyw", line 215, in 
File "core.pyc", line 545, in main
File "wx\core.pyc", line 2134, in MainLoop
File "gui\__init__.pyc", line 1052, in Notify
File "core.pyc", line 515, in run
File "queueHandler.pyc", line 83, in pumpAll
File "queueHandler.pyc", line 50, in flushQueue
File "eventHandler.pyc", line 64, in _queueEventCallback
File "eventHandler.pyc", line 216, in executeEvent
File "comtypesMonkeyPatches.pyc", line 101, in newCpbDel
File "comtypes\__init__.pyc", line 918, in __del__
File "comtypes\__init__.pyc", line 1172, in Release
File "comtypesMonkeyPatches.pyc", line 26, in __call__

### Expected behavior:

Dropdown menu is displayed and browseable without remporarily hanging NVDA.

### System configuration
#### NVDA installed/portable/running from source:

Installed

#### NVDA version:

2020.2

#### Windows version:

Windows 10 V2004

#### Name and version of other software in use when reproducing the issue:

Reproducible: Microsoft Edge 85.0.564.41 (oficial build, 64 bits)
Not reproducible: Google Chrome and Mozilla Firefox.

#### Other information about your system:

Add-ons: many from Acapela, Add-on Updater, Application dictionary (incompatible), Clock, Day of the Week, Emoticons, IBMTTS, LION, Remote, Resource Monitor, Speech History, TapinRadio Status Announcer (incompatible), Translate, Weather Plus, Winten Apps. All are reasonably up to date. No other anomalies in the rest of the NVDA initialization messages. Important: Refer to the below info on add-on impact on reproducibility.

### 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.

No

#### If addons are disabled, is your problem still occuring?

Yes

#### Did you try to run the COM registry fixing tool in NVDA menu / tools?

No



Discussion:
<!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
h3
	{mso-style-priority:9;
	mso-style-link:"T\00EDtulo 3 Car";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	font-size:13.5pt;
	font-family:"Calibri",sans-serif;
	font-weight:bold;}
h4
	{mso-style-priority:9;
	mso-style-link:"T\00EDtulo 4 Car";
	mso-margin-top-alt:auto;
	margin-right:0cm;
	mso-margin-bottom-alt:auto;
	margin-left:0cm;
	font-size:12.0pt;
	font-family:"Calibri",sans-serif;
	font-weight:bold;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
span.Ttulo3Car
	{mso-style-name:"T\00EDtulo 3 Car";
	mso-style-priority:9;
	mso-style-link:"T\00EDtulo 3";
	font-family:"Calibri",sans-serif;
	font-weight:bold;}
span.Ttulo4Car
	{mso-style-name:"T\00EDtulo 4 Car";
	mso-style-priority:9;
	mso-style-link:"T\00EDtulo 4";
	font-family:"Calibri",sans-serif;
	font-weight:bold;}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:70.85pt 3.0cm 70.85pt 3.0cm;}
div.WordSection1
	{page:WordSection1;}
/* List Definitions */
@list l0
	{mso-list-id:1684235775;
	mso-list-template-ids:-1;}
ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->Hi all.This problem is also reproducible with the addons disabled. In some cases, when the user press Windows+m NVDA read again, but also is possible that NVDA not responding for 30 seconds.Regards.  Enviado desde Correo para Windows 10 De: Iván NovegilEnviado: lunes, 31 de agosto de 2020 10:25Para: nvaccess/nvdaCC: Carlos-EstebanM; MentionAsunto: [nvaccess/nvda] Problems with the new Facebook interface, Edge 85 and NVDA (#11536) Issue reported by an Spanish-speaking user through Twitter, reproduced by another different user (@Carlos-EstebanM). All the below information is according to original user's comments, as I have been unable to test this as I don't have a active Facebook account with friends to chat with.Steps to reproduceOpen Edge. Chrome and Firefox are working fine with this.Switch to the new Facebook desktop interface (not the usual one).Enter a chat.Press any "Message Actions" button, that is supposed to show a dropdown menu.Actual behavior:NVDA core freezes throwing an exception to the log. Message actions dropdown is not accessible after NVDA auto-recovery. Could be related to #10895.ERROR - eventHandler.executeEvent (15:04:44.730) - MainThread (12848):error executing event: gainFocus on with extra args of {}Traceback (most recent call last):File "speech_init_.pyc", line 523, in getObjectSpeechFile "documentBase.pyc", line 24, in makeTextInfoFile "NVDAObjects\UIA_init_.pyc", line 308, in initNotImplementedError: UIAutomationTextRangeArray is emptyDuring handling of the above exception, another exception occurred:Traceback (most recent call last):File "eventHandler.pyc", line 214, in executeEventFile "eventHandler.pyc", line 94, in initFile "eventHandler.pyc", line 102, in nextFile "C:\Users\USUARIO\AppData\Roaming\nvda\addons\remote\globalPlugins\remoteClient_init_.py", line 426, in event_gainFocusnextHandler()File "eventHandler.pyc", line 102, in nextFile "NVDAObjects\behaviors.pyc", line 185, in event_gainFocusFile "NVDAObjects_init_.pyc", line 1105, in event_gainFocusFile "NVDAObjects_init_.pyc", line 991, in reportFocusFile "speech_init_.pyc", line 478, in speakObjectFile "speech_init_.pyc", line 548, in getObjectSpeechFile "speech\types.pyc", line 50, in flattenNestedSequencesFile "speech\types.pyc", line 50, inFile "speech_init.pyc", line 1127, in getTextInfoSpeechFile "NVDAObjects\UIA_init_.pyc", line 715, in getTextWithFieldsFile "NVDAObjects\UIA_init_.pyc", line 685, in getTextWithFieldsForUIARangeFile "NVDAObjects\UIA_init.pyc", line 685, in getTextWithFieldsForUIARangeFile "NVDAObjects\UIA_init.pyc", line 685, in getTextWithFieldsForUIARange[Previous line repeated 42 more times]File "NVDAObjects\UIA_init.pyc", line 663, in _getTextWithFieldsForUIARangeFile "comtypesMonkeyPatches.pyc", line 26, in callctypes.COMError: (-2147417851, 'El servidor lanzó una excepción.', (None, None, None, 0, None))WARNING - watchdog.watcher (15:04:50.354) - watchdog (9580):Core frozen in stack:File "nvda.pyw", line 215, inFile "core.pyc", line 545, in mainFile "wx\core.pyc", line 2134, in MainLoopFile "gui_init.pyc", line 1052, in NotifyFile "core.pyc", line 515, in runFile "queueHandler.pyc", line 83, in pumpAllFile "queueHandler.pyc", line 50, in flushQueueFile "eventHandler.pyc", line 64, in queueEventCallbackFile "eventHandler.pyc", line 216, in executeEventFile "comtypesMonkeyPatches.pyc", line 101, in newCpbDelFile "comtypes_init.pyc", line 918, in delFile "comtypes_init.pyc", line 1172, in ReleaseFile "comtypesMonkeyPatches.pyc", line 26, in callExpected behavior:Dropdown menu is displayed and browseable without remporarily hanging NVDA.System configurationNVDA installed/portable/running from source:InstalledNVDA version:2020.2Windows version:Windows 10 V2004Name and version of other software in use when reproducing the issue:Reproducible: Microsoft Edge 85.0.564.41 (oficial build, 64 bits)Not reproducible: Google Chrome and Mozilla Firefox.Other information about your system:Add-ons: many from Acapela, Add-on Updater, Application dictionary (incompatible), Clock, Day of the Week, Emoticons, IBMTTS, LION, Remote, Resource Monitor, Speech History, TapinRadio Status Announcer (incompatible), Translate, Weather Plus, Winten Apps. All are reasonably up to date. No other anomalies in the rest of the NVDA initialization messages. Important: Refer to the below info on add-on impact on reproducibility.Other questionsDoes the issue still occur after restarting your computer?YesHave you tried any other versions of NVDA? If so, please report their behaviors.NoIf addons are disabled, is your problem still occuring?YesDid you try to run the COM registry fixing tool in NVDA menu / tools?No—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe. 
cc: @KurtCattiSchmidt, @leonardder, @codeofdusk 

Resolving patch:
diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py
--- a/source/NVDAObjects/UIA/__init__.py
+++ b/source/NVDAObjects/UIA/__init__.py
@@ -1007,11 +1007,21 @@ def kwargsFromSuper(cls,kwargs,relation=None):
 			kwargs['windowHandle'] = None
 		elif relation=="focus":
 			try:
-				UIAElement=UIAHandler.handler.clientObject.getFocusedElementBuildCache(UIAHandler.handler.baseCacheRequest)
-				# This object may be in a different window, so we need to recalculate the window handle.
-				kwargs['windowHandle']=None
+				UIAElement = UIAHandler.handler.clientObject.getFocusedElementBuildCache(
+					UIAHandler.handler.baseCacheRequest
+				)
 			except COMError:
 				log.debugWarning("getFocusedElement failed", exc_info=True)
+				return False
+			# Ignore this object if it is non native.
+			if not UIAHandler.handler.isNativeUIAElement(UIAElement):
+				if UIAHandler._isDebug():
+					log.debug(
+						"kwargsFromSuper: ignoring non native element with focus"
+					)
+				return False
+			# This object may be in a different window, so we need to recalculate the window handle.
+			kwargs['windowHandle'] = None
 		else:
 			UIAElement=UIAHandler.handler.clientObject.ElementFromHandleBuildCache(windowHandle,UIAHandler.handler.baseCacheRequest)
 		if not UIAElement:


Test patch: