Finder often losing focus

I have a strange problem with Finder losing focus. Actually you can find a few matching search results for similar problems.

iMac 2020, MacOS Big Sur 11.6.2 (but it’s been happening for a few versions prior to this.)

Intermittently, perhaps 1 to 5 times a day, if I am browsing in Finder via keyboard, or if I have Quick Preview open on media that I’m reviewing, Finder will lose focus on its windows. The Finder application still has focus. But the keyboard is no longer focused on any of the open windows, and Quick Preview will quit previewing any particular file I had open.

And then sometimes if I’m browsing files, after losing focus I’ll also lose my place, and the focus will end up on the first file at the top when I return to the window.

I’m trying to think of ways that I could narrow down what is causing this.

I am certainly not accidentally hitting any input device.

I first suspected Signiant app, which I used to transfer client files over their network. I uninstalled it, but there were some leftover plist files. I was getting an intermittent log error, and it showed up right around the time it happened. But then while I was monitoring logs, the Signiant error happened again, and Finder did NOT lose focus. (Still, I just removed every last signiant file from my Library.)

Finally, I was waiting for it to happen again, and this log just happened. Could this be related in any way?

settimeofday seems to run about twice per hour. Any way I can trigger this manually as a test?

Dec 22 15:17:59 Rigmarole-iMac timed[114]: settimeofday({0x61c39607,0x751bb}) == 0

EDIT UPDATE: I was monitoring it for another half hour, and it happened again right at the time that settimeofday triggered. Can anyone suggest how I might prevent this? (assuming it isn’t a false positive.)

I can now confirm that it’s the settimeofday function. I can reproduce it.

If I hit spacebar and play a piece of media (movie, mp3, whatever) in Quick Preview, and then go to the system preferences, unlocking authentication in “Date & Time” or “Time Zone” triggers the problem, and the media stops playing, and the focus on the file is lost. (In my gif the focus on the file doesn’t get lost, but the window blinks briefly, and then playback stops and resets to 00:00.)

Same if I disable automatic time and then set it, change the date/time, etc.

Can anyone confirm this? Can anyone try this and it doesn’t cause the problem for you?