kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.36k stars 128 forks source link

Google Chrome resizing/re-positioning weirdly #279

Closed GRardB closed 3 years ago

GRardB commented 3 years ago

Very recently, I encountered a bug(?) which only occurs with Google Chrome. In the attached video, I am "centering" and maximizing two windows: one from Finder, and one from Chrome.

https://user-images.githubusercontent.com/748180/124414030-e162b800-dd1f-11eb-91bf-61ea427e9b57.mov

This is the code for these behaviors:

Key.on('m', ['control', 'option', 'command'], function() {
  const w = Window.focused()

  w.maximize()
})

Key.on('c', ['control', 'option', 'command'], function() {
  const w = Window.focused()

  w.setTopLeft({
    x: getFullWidth() * 0.125,
    y: getFullHeight() * 0.125,
  })

  w.setSize({
    width: getFullWidth() * 0.75,
    height: getFullHeight() * 0.75,
  })
})

For the Finder window, everything works as expected. My keyboard shortcut sequence is:

  1. cmd + optional + command + c
  2. cmd + optional + command + m
  3. cmd + optional + command + c

With Chrome, however, only one action happens for each shortcut attempt. The sequence shown in the video is:

  1. cmd + optional + command + c
  2. cmd + optional + command + c
  3. cmd + optional + command + c
  4. cmd + optional + command + m
  5. cmd + optional + command + m
  6. cmd + optional + command + m
  7. cmd + optional + command + c
  8. cmd + optional + command + c

Basically, each time the function runs, it only performs one step in the process towards the desired final state, skipping any steps whose end states are already reached. Also noteworthy is that the Chrome window resizes and moves smoothly, which didn't happen until recently.

Electron apps don't suffer from the same issue, nor do Firefox or Safari. Lastly, this happens with all of my configured actions, not just these two.

I think this is likely an issue with Chrome and not Phoenix, but my wife doesn't experience this with Rectangle on the same versions of Chrome and macOS (AFAIK, at least). I wonder if there is a workaround for this, either on my end or on Phoenix's?

GRardB commented 3 years ago

I actually think I've fixed the issue. I can't say for sure, since I was doing a lot of things—all of which were unrelated to Phoenix—but my guess is that restarting my computer is what did it.

goerwin commented 2 years ago

I also started seeing this issue, after quitting Chrome and open it again fixed the issue, but still odd behavior.

kasper commented 2 years ago

@goerwin Sorry to hear, out of interest, does Chrome report the resize was successful through the API in these cases?

goerwin commented 2 years ago

Haven't been able to reproduce it again, but I also saw the same behavior for iTerm. But after closing/reopening them the issue went away. I haven't use the API for other than resize/move windows, but I can report back with that info if it happens again

kasper commented 2 years ago

@goerwin Thanks! Usually these should be just caused by the app not following the request or sizing constraints in the app not allowing a particular size, but some apps seem to be more prone to errors than others.

j6k4m8 commented 6 months ago

Seeing the same on v4.0.0 on macOS 14.3 Sonoma with Firefox 122.0.1, seems a bit sporadic, sometimes reboots help and sometimes they don't... not a showstopper but wanted to share!