I have a set of macros that I use to position windows. In the past they've worked instantaneously. Recently, certain steps fail to execute. Unfortunately I upgraded to KM11 and Sonoma at around the same time, so I can't be sure which change introduced the problem.
As an example, this macro should make the front window fit itself to the available screen space. It still works as expected with some applications (Messages, the KM editor, Slack, ReadKit) but fails with others (Safari, Finder, Tot, BBEdit). When it fails, the window sometimes resizes without repositioning, or repositions but not to the correct spot. Also, the resizing and repositioning is slower in the failure cases — in the success cases, the window snaps into position almost immediately, but in the failure cases it visibly slides over.
Adding a 0.2 second pause between the steps fixes the problem.
My best guess is some change to certain kinds of window in Sonoma is messing with KM's Screen functions.
This is a fairly well-documented issue, dating back at least a couple of years. In my experience, it seems to appear out of nowhere, and can be related to an OS upgrade, or completely random. One of the times I experienced it on a previous machine, reinstalling the OS permanently fixed it. But if you don’t feel like doing that, there are workarounds you can try as well.
If you add a 0.3 second pause between the actions, then it should work reliably in most case I believe.
The issue appears to be that the system (sometimes?) animates the changes, and that making another request while the animation is in process results in the system getting confused.
I have reported this to Apple, and the next version of Keyboard Maestro will include the 0.3s delay, although that is exceptionally annoying since it means that the delay always happens even with the animations/issues only sometimes happen, but that is probably better in the name of reliability.
Thanks Peter. The delay does fix it, although now the windows do a weird little dance before landing in the right size and position — I miss when they would just snap straight into place. Hopefully Apple will fix eventually.
Sadly, this is a response to an issue in the system that means that sometimes resizing windows performs an animation. Changing a window position moves and resizes the window in two steps (there is no single API for move&resize). And if the resize happens while the animation is happing, then the system screws up both. To work around this and ensure reliability, Keyboard Maestro includes a delay between the actions.
So you can have fast and unreliable, or slow and reliable, but not fast and reliable.