Repository: nvaccess/nvda

Issue:
Errors when opening Firefox tabs, navigating Explorer, etc.: Dynamic_MultitaskingViewFrameListItemListItemUIA' object has no attribute 'IAccessibleObject

### Steps to reproduce:

Install or run latest alpha.
Open one or more pages in Firefox.

Alternate:
Open Windows Explorer, and move up and down a file list.

### Actual behavior:

Upon opening a new page, changing tabs, or changing windows, Multiple error sounds play, and a chain of exceptions is shown in the log:

```
ERROR - api.setFocusObject (01:24:28.593) - MainThread (7352):
Error updating tree interceptor
Traceback (most recent call last):
  File "api.pyc", line 139, in setFocusObject
  File "treeInterceptorHandler.pyc", line 33, in update
  File "NVDAObjects\__init__.pyc", line 389, in _get_treeInterceptor
  File "treeInterceptorHandler.pyc", line 25, in getTreeInterceptor
  File "virtualBuffers\gecko_ia2.pyc", line 226, in __contains__
  File "virtualBuffers\gecko_ia2.pyc", line 185, in _iterIdsToTryWithAccChild
AttributeError: 'Dynamic_MultitaskingViewFrameListItemListItemUIA' object has no attribute 'IAccessibleObject'
ERROR - eventHandler.executeEvent (01:24:28.645) - MainThread (7352):
error executing event: foreground on <NVDAObjects.UIA.UIA object at 0x072A13B8> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 246, in executeEvent
  File "eventHandler.pyc", line 96, in __init__
  File "eventHandler.pyc", line 103, in next
  File "eventHandler.pyc", line 131, in gen
  File "NVDAObjects\__init__.pyc", line 389, in _get_treeInterceptor
  File "treeInterceptorHandler.pyc", line 25, in getTreeInterceptor
  File "virtualBuffers\gecko_ia2.pyc", line 226, in __contains__
  File "virtualBuffers\gecko_ia2.pyc", line 185, in _iterIdsToTryWithAccChild
AttributeError: 'UIA' object has no attribute 'IAccessibleObject'
DEBUGWARNING - NVDAObjects.UIA.UIA._prefetchUIACacheForPropertyIDs (01:24:28.669) - MainThread (7352):
IUIAutomationElement.buildUpdatedCache failed given IDs of {30019, 30086, 30022, 30025, 30155, 30036, 30070, 30103, 30008, 30009, 30010, 30046, 30079}
DEBUGWARNING - eventHandler.executeEvent (01:24:28.675) - MainThread (7352):
error executing event: gainFocus on <NVDAObjects.Dynamic_MultitaskingViewFrameListItemListItemUIA object at 0x0711F238> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 246, in executeEvent
  File "eventHandler.pyc", line 96, in __init__
  File "eventHandler.pyc", line 105, in next
  File "appModules\explorer.pyc", line 415, in event_gainFocus
  File "eventHandler.pyc", line 105, in next
  File "NVDAObjects\UIA\__init__.pyc", line 1142, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1137, in event_gainFocus
  File "NVDAObjects\__init__.pyc", line 1005, in reportFocus
  File "speech\__init__.pyc", line 449, in speakObject
  File "speech\__init__.pyc", line 491, in getObjectSpeech
  File "speech\__init__.pyc", line 355, in getObjectPropertiesSpeech
  File "baseObject.pyc", line 42, in __get__
  File "baseObject.pyc", line 146, in _getPropertyViaCache
  File "NVDAObjects\UIA\__init__.pyc", line 1599, in _get_rowNumber
  File "NVDAObjects\UIA\__init__.pyc", line 839, in _getUIACacheablePropertyValue
  File "comtypesMonkeyPatches.pyc", line 27, in __call__
_ctypes.COMError: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None))
ERROR - eventHandler.executeEvent (01:24:28.682) - MainThread (7352):
error executing event: UIA_window_windowOpen on <appModules.explorer.MultitaskingViewFrameWindow object at 0x072D3B80> with extra args of {}
Traceback (most recent call last):
  File "eventHandler.pyc", line 246, in executeEvent
  File "eventHandler.pyc", line 96, in __init__
  File "eventHandler.pyc", line 105, in next
  File "appModules\explorer.pyc", line 439, in event_UIA_window_windowOpen
  File "eventHandler.pyc", line 103, in next
  File "eventHandler.pyc", line 131, in gen
  File "NVDAObjects\__init__.pyc", line 389, in _get_treeInterceptor
  File "treeInterceptorHandler.pyc", line 25, in getTreeInterceptor
  File "virtualBuffers\gecko_ia2.pyc", line 226, in __contains__
  File "virtualBuffers\gecko_ia2.pyc", line 185, in _iterIdsToTryWithAccChild
AttributeError: 'MultitaskingViewFrameWindow' object has no attribute 'IAccessibleObject'
```

### Expected behavior:

No error sounds, no errors.

### System configuration
#### NVDA

Installed, alpha-22148,9a1cca54

#### Windows version:

20H2 (OS Build 19042.867)

#### Name and version of other software in use when reproducing the issue:

Firefox 87.0 (64 bit)

#### Other information about your system:

### 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.

An earlier alpha from today didn't do this.
2019.3.1 doesn't do this.

#### If add-ons are disabled, is your problem still occurring?

Yes
#### Did you try to run the COM registry fixing tool in NVDA menu / tools?

Yes

[log](https://github.com/nvaccess/nvda/files/6209613/errors.when.changing.tabs.txt)



Discussion:
CC: @seanbudd @feerrenrut 
I think possibly related to #12232, cc: @lukaszgo1 

Resolving patch:
diff --git a/source/virtualBuffers/gecko_ia2.py b/source/virtualBuffers/gecko_ia2.py
--- a/source/virtualBuffers/gecko_ia2.py
+++ b/source/virtualBuffers/gecko_ia2.py
@@ -214,8 +214,8 @@ def _iterIdsToTryWithAccChild(cls, obj):
 			yield accId
 
 	def __contains__(self,obj):
-		if not (
-			(
+		if (
+			not (
 				isinstance(obj, NVDAObjects.IAccessible.IAccessible)
 				and isinstance(obj.IAccessibleObject, IA2.IAccessible2)
 			)


Test patch: