Logging how NVDA tracks focus

Felix G.

I am currently searching for clues why NVDA sometimes fails to track focus. Remember those moments when you launch a program, a window opens but NVDA doesn't announce it, even insisting you are still on the desktop when you ask it via NVDA+t? Or those times when it just says "Mozilla Firefox," ignoring that focus has long since moved on to the address bar? The common denominator of all these scenarios is this: NVDA has lost track of the focus, believing it where it once was rather than where it is now.
The proof can be found by pressing NVDA+f1 in those cases, requesting technical information about the current navigator object. If we assume NVDA is configured so that the navigator object follows focus, this technical information should always indicate that the object in question indeed has focus. And in most cases it does. Just not in those special cases I'm trying to hunt down. In those instances, I am always rewarded with the line:
hasFocus: False
So, even though the navigator object has been set up to follow the focus, it has somehow ended up on an object which doesn't have focus. Or to put this differently: Focus has moved on, leaving the navigator object trailing behind like a shadow at sunset.
Which makes me wonder: Is there a way to log how NVDA tracks focus? In other words, is there a way to tell NVDA to log each incoming event which makes it think the focus has changed, and also where it thinks it went? The time has come that we once and for all find out where things go wrong. Is it a UIA event that never arrives? One which arrives but has wrong parameters? One which arrives but is incorrectly interpreted?
I tried setting the log level to debug but in the resulting logs I saw nothing pertaining to focus events. That's why I'm asking.
All the best,

Join nvda@nvda.groups.io to automatically receive all group messages.