-
-
Notifications
You must be signed in to change notification settings - Fork 289
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
Wayland support? #3
Comments
Right now screen casting is not supported for Wayland. Currently the screen is captured either via autopilot, which only supports X11, or using To get Wayland to work there are some things I still need to find out:
If someone wants to help me here a minimal working example of taking a screenshot of a selected window in Wayland would be great, provided it is written in Rust, C or C++. Alternatively point me to a tool that already does that. |
About the input issues: I am not sure what's causing that, I do not do anything specific to X11. Also this should probably be a separate issue. |
Looks like the tool you used (https://github.com/ammen99/wf-recorder) for recording and https://github.com/emersion/grim can be used as a reference. |
Hey @H-M-H, thank you for your willingness to work on Wayland support and I'm sorry I can't do more to help right now. Realistically, I don't think I'm going to be able to help you debug libinput or evtest right now. I love this project and think it's absolutely amazing. Wish I had more time to help out. |
Alright, I totally understand that, thanks for your report anyways! Maybe someone else can help out. |
I did some research and the situation regarding capturing the screen or even windows on wayland is pretty dire. There is no equivalent to X11's
|
What about PipeWire?
|
Interesting, I did not know about PipeWire, the docs are a bit lacking but PipeWire is used by webrtc, so a look at how they do it might help. @pointhi do you know what latency one can expect using PipeWire? For reference: capturing a 1920x1080 raw bgr0 frame on my system takes about 0.8 milliseconds if the screen contents do not change too much. |
I never used PipeWire, but it was designed for remote desktop applications on Wayland to my knowledge. |
strangely enough, unfocused windows do get captured, until the very first event sent to them which focuses them and then the output becomes black |
I think I have a good idea of what's going on: If a window is not focused, Weylus captures it directly by its window handle but if it is active Weylus captures the part of the root window containing the window to be captured. The reason for this is to have things like context menus that are their own windows in themselves still show up. But I guess XWayland doesn't like capturing the root window and just decides to have it black. |
Please check if things work better with the latest build: https://github.com/H-M-H/Weylus/actions/runs/585393503#artifacts |
I started experimenting with pipewire as this seems to be the most promising solution here: https://github.com/H-M-H/Weylus/tree/wayland For now only requesting a screen cast via org.freedesktop.portal.ScreenCast is implemented. That means there now is a file descriptor that can be used to connect to pipewire. Unfortunately the docs on how to use pipewire directly are still very lacking. For example pw_remote_connect_fd mentioned in the docs for org.freedesktop.portal.ScreenCast has been removed in pipewire 0.3 and seems to be pw_context_connect_fd now. All I could find on video processing is: https://gitlab.freedesktop.org/pipewire/pipewire/-/blob/master/doc/tutorial5.md It looks like pipewire implements a gstreamer plugin, I suspect gstreamer's API is not as badly documented, so this is perhaps worth a look. A problem that remains is that it looks like there is no way to get the position of a captured window, which means Weylus won't be able to properly map the input to the window. As it stands only capturing the full desktop will be usable under Wayland. |
Looks like once this is resolved, working with cursor metadata via gstreamer will make dynamically showing and hiding the cursor possible. Regarding window titles I opened a feature request here: flatpak/xdg-desktop-portal#569 |
Thanks a lot for working on this :) |
Thanks! So far walking this path has been rather rocky and I have hit quite some bugs on the way: Bugs
Missing features
Fortunately I could workaround all PipeWire deadlocks and at least on GNOME Weylus can now capture the desktop and windows and so far it seems not too unstable. Feel free to try the latest builds. Considering the current situation I will definitely mark Wayland screen capture experimental and make it opt in. |
Hi, I've tried installing weylus on a Pi 4 running manjaro sway. Everything works other than desktop capture. I can capture chromium tabs and weylus itself, but the desktop capture returns the following warning: WARN weylus::capturable: Failed to get list of capturables via dbus/pipewire: Failed to obtain screen capture. Chromium itself is able to capture the desktop, as I am able to share the screen from web apps such as Microsoft Teams. Before running I set: export XDG_SESSION_TYPE=wayland This works for chromium, and idea what could be done to get it to work in weylus? |
This means that Weylus only captures windows available via XWayland. Please check if https://gitlab.gnome.org/snippets/19 also fails. Some more questions: How exactly does the process for window/desktop selection work with chromium, do you get some kind of popup window that lets you select what to capture and does that popup window also appear for Weylus? |
Hi, also getting
Yes, this snippet works.
Don't know how chromium does this, but firefox (for example https://mozilla.github.io/webrtc-landing/gum_test.html) and the python snippet both change the mouse cursor to a cross and I need to click on a desktop I want to share. Actually, Weylus also does this. Also, input forwarding to desktop does work (but there is no image). EDIT: Arch Linux, Sway WM, AMD gpu |
In Gnome/Mutter, the whole desktop works fine (Entire screen option)! It's pretty cool! Now I wish you could use Mutter's headless stuff and create a virtual screen! :) |
@dron1885 @l-o-l I got it working under sway now, please check if the latest build works for you as well: https://github.com/H-M-H/Weylus/actions/runs/1012629238#artifacts @mattpepin do you know how Mutter's headless stuff works? Perhaps I could add some examples or even an accompanying script to Weylus. |
@H-M-H Can confirm that it's working. Thanks! |
Excellent, thanks for testing!
This is a known problem and sadly not easily fixed. For monitors xdg-desktop-portal provides positions but unfortunately those are compositor dependent/the coordinate system is unspecified and there is no straightforward way to translate them into something useful. For windows the situation is even worse as there is no position given. Unfortunately I do not see this being solved in the foreseeable future. In my opinion the whole screen recording/remote desktop situation around Wayland is most unfortunate. There have been discussions to add screen recording to Wayland for years with the result that the team behind Flatpak is now somehow responsible for this and there are no plans to extend Wayland itself or provide an official API/Protocol. This means the Flatpak devs effectively have full responsibility/control over how screen casting works. The problem now is that Flatpaks focus is not exactly to provide a nice screen cast/remote desktop interface for Wayland [1]. I can not and will not blame them for that, it is totally understandable if they deem some features required to get a nice remote desktop experience working unnecessary for Flatpak. If despite this anyone knows how to obtain the positions of pipewire streams in a way useful to Weylus I very much would like to hear that though. [1]: There actually is a remote desktop interface. But among other things it doesn't handle resizing windows or pressure sensitivity of touch input. |
Hello, just a clarification. What does it mean that for Wayland there is no support for "capturing the cursor"? If I move the stylus on my tablet, will the cursor move accordingly? |
@H-M-H I think something is missing in my setup, but i don't know what. |
@mgonzalezm alright, so autopilot was indeed the cause for the crash. Have you made sure The error message you got means that Weylus could not find any screens or windows to capture. Have you made sure to start Weylus with Regarding |
@H-M-H sorry I forgot and yes
Now I can connect, and select
and only a black screen is shown on the browser I think that not having a wayland compatible gui is not a big deal, as long as the same options be available on the command line. Thank you for your help and your excellent work |
Hmm, this error stems from within gstreamer somewhere in this call to set_state: Weylus/src/capturable/pipewire.rs Line 148 in 33cf5f1
Please check if this snippet works: https://gitlab.gnome.org/-/snippets/19 or alternatively check if OBS can capture your screen. This might be a problem unrelated to Weylus. |
@H-M-H Yes OBS works ok, I can see my screen. I wouldn't now if the snippet works, after the pop-up to select the monitor to share, this is all I can see in the terminal
|
@mgonzalezm I am sorry, I was a little busy with other things the last days. The script I linked should start recording your screen using gstreamer and then open a window that shows the recording. This typically results in some funny recursion to look at. If this is not the case this pretty much verifies that this is a gstreamer issue and not something related to pipewire only (OBS directly interfaces with pipewire, skipping gstreamer). What's the output of |
Hello, I'm facing the same problem as @noneucat, i.e. I get a I'm using NixOS, and I tried running weylus with for example Any idea what could cause this / how to debug ? Thanks. Edit: Running weylus with GST_DEBUG=5, I get more information:
Full log: log.txt |
@rgrunbla: Thanks for looking into this! Also, if this problem persists, please open a separate issue. |
Maybe this solution using vdl and deskreen could be inspiring for Wayland support ? |
@H-M-H @zachlatta This issue should be closed as pipewire support has been added |
It seems to me that, under Wayland (I am using |
It seems to me that under Wayland one cannot select a specific window, but "Pipewire unknown", which shows the current desktop. I am not sure whether it is possible to capture a specific window under Wayland, however.
No, it can't. For security, you select the window only in the pipewire popup. The program can't access every window instantly, and without confirmation. Weylus isn't forwarding the window title, but that's not a problem. To change the window, you can use the 'refresh sources' button, or reload the page, then choose the window you want to mirror on your screen.
For most people, it may be easier to just mirror the whole display. With X11 there are normally no controls to what programs can access on the same server. Giving access to the monitor through Pipewire doesn't give access to all windows.
You *may* still be able to access X11 windows directly through Weylus, but you won't be able to access Wayland windows.
|
I am not sure whether I misconfigured something. I compiled the latest Weylus without compiling I have exactly tried this: after clicking "refresh", the mouse icon becomes a cross, which seems to indicate me to select a windows, and after selection, the title of selected window does not appear in the drop list. |
Weylus doesn't forward the window title to the client. Just select Pipewire, which is usually selected by default. You will probably only be able to access the window you selected.
25 Aug 2023 11:27:48 Iey4iej3 ***@***.***>:
…
To change the window, you can use the 'refresh sources' button, or reload the page, then choose the window you want to mirror on your screen.
I am not sure whether I misconfigured something. I compiled the latest Weylus without compiling *ffmpeg* (I failed to compile *ffmpeg* for some reasons). I am under *sway*.
I have exactly tried this: after clicking "refresh", the mouse icon becomes a cross, which seems to indicate me to select a windows, and after selection, the title of selected window does not appear in the drop list.
—
Reply to this email directly, view it on GitHub[#3 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AD43AYNPVDMEBBJRQXSPJPLXXB42JANCNFSM4NX2ZYHA].
You are receiving this because you commented.[Tracking image][https://github.com/notifications/beacon/AD43AYMC6LXKNZHYHOMI7GTXXB42JA5CNFSM4NX2ZYHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMTVU6XQ.gif]
|
No, it is accessing the current display (although the cross icon seems to indicate that I was supposed to select a specific window). |
Are you selecting Pipewire or X11 display? The default cursor on X11 is an X. You only choose the window on the actual computer, it should show up on the monitor, once you load the webpage.
25 Aug 2023 11:50:17 Iey4iej3 ***@***.***>:
…
No, it is accessing the current display (although the cross icon seems to indicate that I was supposed to select a specific window).
—
Reply to this email directly, view it on GitHub[#3 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AD43AYJAS3TUYRCCJFRFV33XXB7OTANCNFSM4NX2ZYHA].
You are receiving this because you commented.[Tracking image][https://github.com/notifications/beacon/AD43AYJMVJBVHDB534OEP3TXXB7OTA5CNFSM4NX2ZYHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMTV3JWI.gif]
|
I believe that it is Pipewire (the cursor, more precisely being "+" in place of "X", is very different from the default cursor of X): it is triggered by "refresh list" or truly refreshing the site, and without clicking anything, the window list is empty. |
Yes that is then. The pipewire selection depends on your window manager, so that will be how sway shows it.
25 Aug 2023 12:03:06 Iey4iej3 ***@***.***>:
…
Are you selecting Pipewire or X11 display? The default cursor on X11 is an X. You only choose the window on the actual computer, it should show up on the monitor, once you load the webpage. 25 Aug 2023 11:50:17 Iey4iej3 /*@*/.***>:
I believe that it is Pipewire (the cursor, more precisely being "+" in place of "X", is very different from the default cursor of X): it is triggered by "refresh list" or truly refreshing the site, and without clicking anything, the window list is empty.
—
Reply to this email directly, view it on GitHub[#3 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AD43AYOS6UUNMKM3YRCKQZTXXCA6VANCNFSM4NX2ZYHA].
You are receiving this because you commented.[Tracking image][https://github.com/notifications/beacon/AD43AYKUMBU6SNR5JT3S3FTXXCA6VA5CNFSM4NX2ZYHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMTV64SY.gif]
|
After having searched, I see that it is an issue of |
To anyone getting |
For any Arch + PipeWire users getting the |
Is there a way for non Gnome and KDE wayland users to use weylus with video when it relies on org.freedesktop.impl.portal.RemoteDesktop? Only the KDE and Gnome portals have implemented it yet and I can't get them to work under Hyprland. It's not ideal if only these two IDE's can use video sharing on wayland |
@dryBoneMarrow as far as I understand the Hyprland wiki about screen sharing it is supposed to work with |
On KDE Neon 6.2, weylus just refuses to work: Failed to init screen cast! |
This make linux builds hybird wayland/x11 instead of them being x11 only currently, with the slight downside of requiring wayland for building (not a problem for CI, and I think the amount of people who are building from source on x11 only systems is small). See this issue for more detail: fltk-rs/fltk-rs#1602 Fixes H-M-H#3.
Does this project support Wayland? I'm running the latest on https://aur.archlinux.org/packages/weylus-bin/ and while I have input working, I'm getting a black screen on the iPad browser I'm using it from.
Input also seems to be smooth in Xwayland apps, but jumpy in Wayland native apps.
Update: See recording of this at https://www.youtube.com/watch?v=GrJXqqLKas4. All input is made via Apple Pencil on an iPad. Notice that the input is smooth when over xeyes, but jumpy over Alacritty (which is a Wayland app).
The text was updated successfully, but these errors were encountered: