I am the developer of the tool MaxTo, and I've had reports of what we initially thought was an incompatibility between MaxTo and KeePass, but seems to have to be fixed on KeePass' end.
The issue is that searching in KeePass will cause any .NET program that is listening for UI Automation events that include the KeePass window will start producing Win32Exception's regularly in the background, causing it to use quite a bit of CPU until KeePass exits.
The minimal reproduction I've been able to produce is this (can be run in e.g. LINQpad 5):
void Main()
{
Automation.AddAutomationEventHandler(
WindowPattern.WindowOpenedEvent,
AutomationElement.RootElement,
TreeScope.Subtree,
this.OnWindowOpen);
Console.ReadLine();
}
private void OnWindowOpen(object sender, AutomationEventArgs e)
{
}
This code basically sets up a listener for all window opened events in the system; so it has to be running before you start KeePass.
I am not sure as to the reason why this happens in KeePass, but I leave that for you to figure out. :)
I've created the test application that you suggested, started it, started KeePass and did various things (opened a database, added an entry, etc.), but cannot reproduce the issue. Neither in the test application nor in KeePass an exception is thrown, and I also cannot observe a high CPU usage.
Can you please provide additional information for reproducing the issue? For example, the KeePass configuration file and detailed steps what you're doing might be helpful. Make sure that you perform tests without any plugin.
Thanks and best regards,
Dominik
Thank you for looking at this. I am attaching a LINQpad file that you can run. Screenshot follows in next post (can't post two attachments at once)
To reproduce reliably I:
Screenshot.
I can reproduce the higher CPU usage now (no exceptions though). I'll look into it.
Thanks and best regards,
Dominik
This seems to be a bug in the UI automation (or the .NET Framework).
I've created a small demo application for reproducing the problem; see the attached UIAutoBug.zip file. It shows a form with a list view and a button. In order to reproduce the problem, run your UI automation LINQPad file and click the button in the demo application; this adds a few groups and items to the list view and often results in a high CPU usage. The high CPU usage doesn't occur always, but often (in my tests with about 50% probability when clicking the button about 2 seconds after starting the demo application).
When the bug occurs, the UI automation code seems to continuously handle events through
MS.Internal.AutomationProxies.WindowsListView.GroupSpecificEvents(which invokes anIsGroupViewEnabledmethod that sendsLVM_ISGROUPVIEWENABLEDandLVM_GETVIEWmessages to the demo application, which explains why both applications have a high CPU usage). I haven't found out why it does that.The way how the groups and items are added to the list view looks completely normal to me; nothing special. Have you seen a problem like this before? Is there any workaround?
Thanks and best regards,
Dominik