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

Crash on Wayland, XGetImage failed #76

Closed
Igetin opened this issue Apr 23, 2020 · 4 comments · Fixed by #77
Closed

Crash on Wayland, XGetImage failed #76

Igetin opened this issue Apr 23, 2020 · 4 comments · Fixed by #77
Assignees
Labels
enhancement New feature or request

Comments

@Igetin
Copy link

Igetin commented Apr 23, 2020

NormCap crashes when trying to run it under Wayland:

20:29:41 - INFO - normcap.normcap - Starting NormCap v0.1.2 ...
Traceback (most recent call last):
  File "/home/ige/.local/bin/normcap", line 10, in <module>
    sys.exit(run())
  File "/home/ige/.local/lib/python3.7/site-packages/normcap/__main__.py", line 5, in run
    _ = main()
  File "/home/ige/.local/lib/python3.7/site-packages/normcap/normcap.py", line 153, in main
    normcap_data = client_code(capture, normcap_data)
  File "/home/ige/.local/lib/python3.7/site-packages/normcap/normcap.py", line 106, in client_code
    result = handler.handle(normcap_data)
  File "/home/ige/.local/lib/python3.7/site-packages/normcap/handlers/capture_handler.py", line 26, in handle
    request = self._take_screeshot(request)
  File "/home/ige/.local/lib/python3.7/site-packages/normcap/handlers/capture_handler.py", line 40, in _take_screeshot
    raw = sct.grab(position)
  File "/home/ige/.local/lib/python3.7/site-packages/mss/linux.py", line 403, in grab
    ZPIXMAP,
  File "/home/ige/.local/lib/python3.7/site-packages/mss/linux.py", line 175, in validate
    raise ScreenShotError(err, details=details)
mss.exception.ScreenShotError: XGetImage() failed
@dynobo
Copy link
Owner

dynobo commented Apr 24, 2020

Thanks for the report, @Igetin . I can reproduce the problem on Ubuntu 20.04 with Gnome under Wayland.

This is probably an issue in the python library mss, which I'm leveraging to get the screenshot on the multiple platform.

Just to be sure, can you please also run the following snippet, e.g. by typing it in python3 console, can you confirm that you experience the same behavior as described below?

If I run only the following lines...

import mss
fn = mss.mss().shot(mon=-1, output="screenshot.png")
print(fn)

...under X it works (filename is printed, screenshot saved), while under Wayland I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/holger/.local/lib/python3.8/site-packages/mss/factory.py", line 41, in mss
    return linux.MSS(**kwargs)
  File "/home/holger/.local/lib/python3.8/site-packages/mss/linux.py", line 226, in __init__
    self.root = self.xlib.XDefaultRootWindow(MSS.display)
  File "/home/holger/.local/lib/python3.8/site-packages/mss/linux.py", line 175, in validate
    raise ScreenShotError(err, details=details)
mss.exception.ScreenShotError: XDefaultRootWindow() failed

@dynobo dynobo self-assigned this Apr 24, 2020
@dynobo dynobo added the bug Something isn't working label Apr 24, 2020
@dynobo
Copy link
Owner

dynobo commented Apr 24, 2020

I opened an issue for mss: BoboTiG/python-mss#155

Beside waiting to get it fixed in that dependency, I'll think about a (temporary) workaround, e.g. by falling back to pyscreenshot or an execution of gnome-screenshot. But I'll have to check, if the effort is worth the temporary benefit. Stay tuned! :-)

@dynobo dynobo added enhancement New feature or request and removed bug Something isn't working labels Apr 24, 2020
@dynobo dynobo mentioned this issue Apr 25, 2020
Merged
@dynobo
Copy link
Owner

dynobo commented Apr 25, 2020

I added a fallback for wayland. However, that workaround uses gnome-screenshot tool, which have to be installed (it is by default on Ubuntu). Please test and report back, if it worked.

@Igetin
Copy link
Author

Igetin commented Apr 28, 2020

The gnome-screenshot workaround works, thank you.

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

Successfully merging a pull request may close this issue.

2 participants