Bug report: Window positioning + resize failing in KM11 / Sonoma

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.

Window Position-Resize Demo.kmmacros (26 KB)

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.

Note Peter's comments on one particular post:

Ah, thanks for this information. Annoying that it’s a longstanding macOS bug, but it looks like there are a few workaround options for me to explore.

1 Like

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.

1 Like

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.

The Set Action Delay action in KM would be a very good place to let the user control that feature. It was made just for that sort of thing.

1 Like

Hi,

I just tried both versions. I might add that KM 11.0.1 is fast and KM 11.0.2 is much slower on Monterey 12.7.1

For me everything works (no fails that I see) but this (and possibly other macros) seem sluggish on v11.0.2

Is there a link to re download v 11.0.1?

What you are seeing is, I believe, due to exactly what @peternlewis said would happen, earlier in this very topic:

-rob.

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.

You can turn this off with the Terminal command:

defaults write com.stairways.keyboardmaestro.engine WindowSetFrameAnimationTime -float 0.0

But you may find that some windows in some applications (including Safari and Mail) may start to fail to correctly perform move&resize actions.

1 Like