Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"could not locate window with the specified id" or "could not locate the window to act on!" #2320

Closed
pyinto opened this issue Jun 8, 2024 · 4 comments

Comments

@pyinto
Copy link

pyinto commented Jun 8, 2024

Having some issues when I try to focus specific app by it's ID, it was hard to debug because I don't have any concrete steps to reproduce this behavior, and list of the apps affected differs too. Recently I cough one of such examples when my debug logs was open, here how it looked like:

$yabai -m query --windows
{
        "id":527,
        "pid":19161,
        "app":"Telegram",
        "title":"",
        "scratchpad":"",
        "frame":{
                "x":3368.0000,
                "y":-594.0000,
                "w":1676.0000,
                "h":2968.0000
        },
        "role":"",
        "subrole":"",
        "root-window":true,
        "display":2,
        "space":5,
        "level":0,
        "sub-level":0,
        "layer":"normal",
        "sub-layer":"normal",
        "opacity":1.0000,
        "split-type":"none",
        "split-child":"none",
        "stack-index":0,
        "can-move":false,
        "can-resize":false,
        "has-focus":false,
        "has-shadow":true,
        "has-parent-zoom":false,
        "has-fullscreen-zoom":false,
        "has-ax-reference":false,
        "is-native-fullscreen":false,
        "is-visible":false,
        "is-minimized":false,
        "is-hidden":false,
        "is-floating":false,
        "is-sticky":false,
        "is-grabbed":false
}

Then I try to switch to it and next thing happens:

$ yabai -m window --focus 527
could not locate window with the specified id '527'.
$ yabai -m window --focus '527'
could not locate window with the specified id '527'.

or

could not locate the window to act on!

The app is the only visible app in space 5 (when I am at space 6 if that matters) on my second display. I didn't restart it, nor did I restart Yabai, and suddenly it's working again. Here is a query response for that window after it started to work again:

{
        "id":527,
        "pid":19161,
        "app":"Telegram",
        "title":"Telegram",
        "scratchpad":"",
        "frame":{
                "x":3368.0000,
                "y":-594.0000,
                "w":1676.0000,
                "h":2968.0000
        },
        "role":"AXWindow",
        "subrole":"AXStandardWindow",
        "root-window":true,
        "display":2,
        "space":5,
        "level":0,
        "sub-level":0,
        "layer":"normal",
        "sub-layer":"normal",
        "opacity":1.0000,
        "split-type":"none",
        "split-child":"second_child",
        "stack-index":0,
        "can-move":true,
        "can-resize":true,
        "has-focus":false,
        "has-shadow":true,
        "has-parent-zoom":false,
        "has-fullscreen-zoom":false,
        "has-ax-reference":true,
        "is-native-fullscreen":false,
        "is-visible":false,
        "is-minimized":false,
        "is-hidden":false,
        "is-floating":false,
        "is-sticky":false,
        "is-grabbed":false
}

As you can see both role and subrole were messed up, but again, it was perfectly fine window that was working as usual, I did nothing to fix and it works. It's not about this specific app, it happens rarely and randomly with a list of apps.

Any ideas what's going on or how I can fix it? I also sometimes experience issues when my queries are taking much more time to respond, but I guess that's not related.
Would be great to hear your thoughts or propositions on how to further investigate it. Thanks!

Mac OS: 14.5 (23F79)
yabai-v7.1.1
No scripting additions installed.

@iamyojimbo
Copy link

I am also experiencing this from time to time. Seemed to happen after my machine went to sleep. When it started up again, commands like this stopped working only for some windows:

~ yabai -m window --focus $(yabai -m query --windows | jq '[.[] | select(.app == "Safari")] | sort_by(.display) | reverse | .[0].id ')
could not locate window with the specified id '2885'.

Here's the output of the query:

~ yabai -m query --windows | jq '[.[] | select(.app == "Safari")]'
[
  {
    "id": 2885,
    "pid": 1189,
    "app": "Safari",
    "title": "",
    "scratchpad": "",
    "frame": {
      "x": 1728.0000,
      "y": 0.0000,
      "w": 1920.0000,
      "h": 1080.0000
    },
    "role": "",
    "subrole": "",
    "root-window": true,
    "display": 2,
    "space": 9,
    "level": 0,
    "sub-level": 0,
    "layer": "normal",
    "sub-layer": "normal",
    "opacity": 1.0000,
    "split-type": "none",
    "split-child": "none",
    "stack-index": 0,
    "can-move": false,
    "can-resize": false,
    "has-focus": false,
    "has-shadow": true,
    "has-parent-zoom": false,
    "has-fullscreen-zoom": false,
    "has-ax-reference": false,
    "is-native-fullscreen": true,
    "is-visible": false,
    "is-minimized": false,
    "is-hidden": false,
    "is-floating": false,
    "is-sticky": false,
    "is-grabbed": false
  },
  {
    "id": 106,
    "pid": 1189,
    "app": "Safari",
    "title": "\"could not locate window with the specified id\" or \"could not locate the window to act on!\" · Issue #2320 · koekeishiya/yabai",
    "scratchpad": "",
    "frame": {
      "x": 0.0000,
      "y": 37.0000,
      "w": 1728.0000,
      "h": 1080.0000
    },
    "role": "AXWindow",
    "subrole": "AXStandardWindow",
    "root-window": true,
    "display": 1,
    "space": 5,
    "level": 0,
    "sub-level": 0,
    "layer": "normal",
    "sub-layer": "normal",
    "opacity": 1.0000,
    "split-type": "none",
    "split-child": "none",
    "stack-index": 0,
    "can-move": false,
    "can-resize": true,
    "has-focus": false,
    "has-shadow": true,
    "has-parent-zoom": false,
    "has-fullscreen-zoom": false,
    "has-ax-reference": true,
    "is-native-fullscreen": true,
    "is-visible": false,
    "is-minimized": false,
    "is-hidden": false,
    "is-floating": false,
    "is-sticky": false,
    "is-grabbed": false
  }
]

In this case, it is able to select the second window (106), but not the first (2885), I.e. the command works when JQ doesn't reverse the list.

My OS info is:

14.4.1 (23E224) on Apple M2 Max

@koekeishiya
Copy link
Owner

Some window properties are only accessible when yabai has a valid AX-reference for that window.
This AX-reference can only be retrieved when the space that the window is visible on, is active.
If windows are already opened on inactive spaces when yabai is launched, yabai can detect those
windows and retrieve a limited amount of information about them. In addition, yabai window commands
will NOT WORK for these windows. These windows can be identified by looking at the has-ax-reference
property. Once the space that the window belongs to becomes active, yabai will automatically create
an AX-reference. The queries will from that point forwards contain complete information, and the window
can be used with yabai window commands.

https://github.com/koekeishiya/yabai/blob/master/doc/yabai.asciidoc#query

@Kiruel
Copy link

Kiruel commented Sep 17, 2024

Hello anyone find a solution to this ?

@koekeishiya
Copy link
Owner

Implemented workaround on master branch to properly detect these windows on inactive spaces

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants