Giter VIP home page Giter VIP logo

Comments (11)

shvchk avatar shvchk commented on July 20, 2024 1

Made a simple sh wrapper to work around this: https://gist.github.com/shvchk/ecfcb9c43050a08cb55ece9efb935da9

from xdotool.

jordansissel avatar jordansissel commented on July 20, 2024

I wonder if this is a race condition. search will list windows (via XQueryTree), then, for each window listed, queries the window's properties.

If a window is given by XQueryTree, and then before the window properties are queried, that window is deleted, then I could see how this error occurs.

The fix may be to have libxdo's search feature ignore BadWindow errors.

from xdotool.

marcelpaulo avatar marcelpaulo commented on July 20, 2024

Is there any other circumstance that might cause a BadWindow error, or is this the only one ?

Would you have any suggestion on how I could debug this scenario so that I can give you more information to analyze ? Of course, if you need more information. I confess: my knowledge of X programming is 0.

from xdotool.

kenorb avatar kenorb commented on July 20, 2024

Workaround:

set +e
WINDOW_ID=$(xdotool search --name "Foo*")
set -e

from xdotool.

daver1691 avatar daver1691 commented on July 20, 2024

I'm getting the same problem on Ubuntu 18.04 with xdotool version 3.20160805.1.

If I start the PC, start Firefox, and then later run xdotool to find it, I get the error on the first attempt, then subsequent attempts are fine. The exact circumstances are somewhat difficult to pin down but it will sometimes reappear if I restart Firefox, (I always wait for it to start fully) and then the first attempt after that sometimes fails.

$  xdotool search --classname Navigator
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  15 (X_QueryTree)
  Resource id in failed request:  0x1a343ef
  Serial number of failed request:  402
  Current serial number in output stream:  402
$  xdotool search --classname Navigator
  56623120

I'm now running it twice, dumping errors from the first to /dev/null, but I can try to debug this if anybody's got suggestions as to how.

from xdotool.

 avatar commented on July 20, 2024

I have the problem on Linux Mint 19, with xdotool 3.+20180415.1.

from xdotool.

sabrehagen avatar sabrehagen commented on July 20, 2024
Slack window id from --search: 18874369
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  12 (X_ConfigureWindow)
  Resource id in failed request:  0x1200001
  Serial number of failed request:  18
  Current serial number in output stream:  20
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  3 (X_GetWindowAttributes)
  Resource id in failed request:  0x1200001
  Serial number of failed request:  18
  Current serial number in output stream:  19

xdotool version 3.20160805.1
Ubuntu 19.04

from xdotool.

jlittlenz avatar jlittlenz commented on July 20, 2024

I've been getting this (the X_QueryTree error on first search) since I release upgraded to Kubuntu 19.10. But today, after a git pull and recompile, it's stopped happening. The previous version was built on 2019-10-03. I had scripted a retry on the first failure, after logging it.
No X windows were opening or closing when the error occurred. Yesterday it reproduced every time.

from xdotool.

tgharib avatar tgharib commented on July 20, 2024

I can confirm that I am getting the same issue on openSUSE tumbleweed with xdotool version 3.20160805.1.

I am running xdotool search --class "dota2" in a terminal bash script. It runs roughly once an hour. Randomly ~5% of the time, it fails with this output:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  15 (X_QueryTree)
  Resource id in failed request:  0x2404083
  Serial number of failed request:  489
  Current serial number in output stream:  489

from xdotool.

jlittlenz avatar jlittlenz commented on July 20, 2024

I now work around this by looping with

    errors=$(xdotool search --name whatever windowactivate 2>&1)
    if [[ -z "$errors" ]]; then
        .... no problem
        break
    fi
   .... log error

Presently, f I invoke the script from a widget in a panel, it fails once every time. The same script from the menu gets no error.

from xdotool.

willbelr avatar willbelr commented on July 20, 2024

The problem persist in xdotool 3.20160805.1-2. When 'xdotool search' is launched repeatedly from a PyQt app, it fails randomly, about 1 time out of 30. Calling the function more slowly, ie. each 2s vs continuous blocking calls) reduce the likelihood of the error, so it look like a race condition..

It can be worked around but it's not pretty

def _embed(self, ref):
        """ Find and embed the terminal window into a QWindow > QWidget > Layout """
        fetch = QtCore.QProcess(self)
        fetch.start(f"xdotool search --sync --classname {ref}")
        fetch.waitForFinished()
        wid = fetch.readAllStandardOutput().split("\n")[0]
        err = str(fetch.readAllStandardError().split("\n")[0])

        if wid:
            self.window = QtGui.QWindow.fromWinId(int(wid))
            self.widget = QtWidgets.QWidget.createWindowContainer(self.window, self)
            self.widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding,QtWidgets.QSizePolicy.Expanding)
            self.gridLayout.addWidget(self.widget, 1, 0, 1, 3)
        elif err.count("BadWindow"):
            # Workaround for 'X Error of failed request: BadWindow (invalid Window parameter)'
            # https://github.com/jordansissel/xdotool/issues/60
            self._embed(ref)
        else:
            print(f"Null window id for '{self.name}': xdotool search --sync --classname {ref}")

from xdotool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.