Skip to content

Commit 12803e9

Browse files
Add significantly more debug logging to UIAHandler (#14256)
Summary of the issue: Although NVDA has a specific uIA debug logging category, this does not really enable all that many more log messages a part from some debug warnings. thus it is almost useless to ask for a user's log with this flag enabled. Description of user facing changes Setting NVDA's log level to debug, and enabling the UIA debug logging category in NVDA's advanced settings panel, will now produce significantly more logging for UIA. This includes logging when all UIA event handler methods are called, along with their parameters, and logging for utility utility methods such as checking if a window or element is native UIA. Description of development approach Added a bunch of methods to UIAHandler for generating a string representation for debugging, for things such as UIA elements, property IDs, event IDs, notification types etc. Added conditional debug logging to all UIA event handler methods, plus isUIAWindow, isNativeUIAElement and getNearestWindowhandle.
1 parent 9a30254 commit 12803e9

4 files changed

Lines changed: 349 additions & 23 deletions

File tree

‎source/IAccessibleHandler/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def winEventToNVDAEvent( # noqa: C901
558558
)
559559
return None
560560
# We do not support MSAA object proxied from native UIA
561-
if UIAHandler.handler and UIAHandler.handler.isUIAWindow(window):
561+
if UIAHandler.handler and UIAHandler.handler.isUIAWindow(window, isDebug=isMSAADebugLoggingEnabled()):
562562
if isMSAADebugLoggingEnabled():
563563
log.debug(
564564
f"Native UIA window. Dropping winEvent {getWinEventLogInfo(window, objectID, childID, eventID)}"

‎source/NVDAObjects/UIA/__init__.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,11 @@ def kwargsFromSuper(cls, kwargs, relation=None, ignoreNonNativeElementsWithFocus
12371237
windowHandle=kwargs.get('windowHandle')
12381238
if isinstance(relation,tuple):
12391239
UIAElement=UIAHandler.handler.clientObject.ElementFromPointBuildCache(POINT(relation[0],relation[1]),UIAHandler.handler.baseCacheRequest)
1240+
if UIAHandler._isDebug():
1241+
log.debug(
1242+
f"kwargsFromSuper: given coordinates {relation}, "
1243+
f"fetched element {UIAHandler.handler.getUIAElementDebugString(UIAElement)}"
1244+
)
12401245
# Ignore this object if it is non native.
12411246
if not UIAHandler.handler.isNativeUIAElement(UIAElement):
12421247
if UIAHandler._isDebug():
@@ -1254,6 +1259,11 @@ def kwargsFromSuper(cls, kwargs, relation=None, ignoreNonNativeElementsWithFocus
12541259
except COMError:
12551260
log.debugWarning("getFocusedElement failed", exc_info=True)
12561261
return False
1262+
if UIAHandler._isDebug():
1263+
log.debug(
1264+
f"kwargsFromSuper: fetched focused element "
1265+
f"{UIAHandler.handler.getUIAElementDebugString(UIAElement)}"
1266+
)
12571267
# Ignore this object if it is non native.
12581268
if ignoreNonNativeElementsWithFocus and not UIAHandler.handler.isNativeUIAElement(UIAElement):
12591269
if UIAHandler._isDebug():
@@ -1294,6 +1304,11 @@ def __init__(self,windowHandle=None,UIAElement=None,initialUIACachedPropertyIDs=
12941304
UIACachedWindowHandle=UIAElement.cachedNativeWindowHandle
12951305
self.UIAIsWindowElement=bool(UIACachedWindowHandle)
12961306
if not windowHandle:
1307+
if UIAHandler._isDebug():
1308+
log.debug(
1309+
f"No windowHandle for UIA NvDAObject. "
1310+
f"Searching UIA element ancestry for nearest windowHandle"
1311+
)
12971312
windowHandle=UIAHandler.handler.getNearestWindowHandle(UIAElement)
12981313
if not windowHandle:
12991314
raise InvalidNVDAObject("no windowHandle")

0 commit comments

Comments
 (0)