element-desktop icon indicating copy to clipboard operation
element-desktop copied to clipboard

Screen sharing fails on Wayland

Open GalouFR opened this issue 1 year ago • 18 comments

Steps to reproduce

When I am in a video conference and I want to share my screen this does not work, the dialog box which allows you to choose between the whole screen and a window appears but it is empty and the share button at the bottom right is grayed out when I use Wayland on the other hand it works correctly with x11 the dialog box shows my screen correctly and I can share it.

Outcome

What did you expect?

I wish to have a fix or solution to make it work natively with the default ubuntu configuration (wayland)

What happened instead?

The share button is grayed out and it is impossible to select the screen or application to share because it does not appear.

Operating system

Ubuntu 22.04 LTS

Application version

Version de Element : 1.11.69, Version crypto : Rust SDK 0.7.0, Vodozemac 0.6.0

How did you install the app?

https://element.io/download

Homeserver

non-public server, synapse server on matrix i think

Will you send logs?

No

GalouFR avatar Jun 27 '24 08:06 GalouFR

just to make sure... do you have an XDG Desktop Portal installed for your desktop env? They are needed for securely accessing resources from outside an application sandbox.

frankenstein91 avatar Jul 05 '24 14:07 frankenstein91

just to make sure... do you have an XDG Desktop Portal installed for your desktop env? They are needed for securely accessing resources from outside an application sandbox.

just to make sure... Where can i see it's needed on the download page ? https://element.io/download#linux

and yes i have: XDG Desktop Portal v1.14.4-1ubuntu2~22.04.1

GalouFR avatar Jul 08 '24 09:07 GalouFR

Hi @GalouFR it is not a requirement of the chat client... It is more of a requirement imposed by Wayland and pipewire.

frankenstein91 avatar Jul 08 '24 11:07 frankenstein91

In https://github.com/element-hq/element-desktop/issues/2058, @Destinyg133 is saying that

I managed to fix it by adding these for electron config "--enable-features=WebRTCPipeWireCapturer"

"--ozone-platform-hint=auto"

You can set these flags more permanently by means of [modifying the .desktop file]of an application and adding the flags to the end of the Exec= line, or more cleanly by using the configuration files.

It didn't work for me though.

Thatoo avatar Feb 02 '25 14:02 Thatoo

There are a bunch of people with this problem. please see above issues marked as dupes

Spengreb avatar Feb 04 '25 09:02 Spengreb

I know, I mention these other issues being duplicate of this oldest one. And all these duplicate issues tends to prove that it's an important one that impact a lot of users. It has something to do with electron as there isn't any issue on element-web, maybe related to https://github.com/electron/electron/issues/41551. I wonder if it would be hard to make an element-desktop based on element-web thanks to https://tauri.app/ instead of electron and would that solve this issue? As I ask the question, I see that an issue is open about this idea : https://github.com/element-hq/element-desktop/issues/771

Thatoo avatar Feb 04 '25 10:02 Thatoo

Screen sharing works in a way for me but is not properly implemented. Selecting a window or entire screen in the pipewore prompt does add an option to application windows in Element. It will re spawn until you close Elemnt but screen sharing should work. If you close the pipewire promt element instantly crashes.

jrndberg avatar Feb 11 '25 08:02 jrndberg

I always thought this as an electron bug, because some other electron apps like discord present the exact same error. I even found https://github.com/electron/electron/issues/45198 which is recent. However, in my system, Manjaro testing / Plasma 6.3, I've downloaded the code to reproduce which attached to the issue and it works in my local system. As it is attached as a way to reproduce the issue in electron, it got me wondering: is this an underlying Electron bug or something in Element itself?

Can someone in their system test it by downloading the files, running electron . in the app directory (or in case of Arch, electron34 .) to check if screen share works? If so, this is not a problem in Electron, but in Element... It is also possible to run npm i then npm start to use a local electron version.

luisfpg avatar Mar 14 '25 17:03 luisfpg

Can confirm that this issue still happens, reproduced the issue running from source with electron36 and KDE Plasma 6.3.5

One notable difference between some of the issues closed as duplicate and the op of this ticket is that the op couldn't press the screenshare button, while in mine and some others the picker shows up, but selections aren't recognized and used, ending in a selection loop. But since the response seems to track both, I'll add it here.

https://github.com/user-attachments/assets/d7268086-aee5-42f5-ace4-7dda383f6e0b

Attaching video (where I list electron version, what commit I'm on and leaving the terminal output in the background)

One thing I can add is that when accessing my self-hosted element call instance with my browser, I can screenshare fine, it is only an issue inside of element-desktop

maspling avatar May 19 '25 21:05 maspling

This is just a lack of Wayland support in element

jrndberg avatar May 20 '25 04:05 jrndberg

Well, this is just a lack of Wayland support in electron.

Well, indeed, this is just a lack of Wayland support in Chromium

Thatoo avatar May 20 '25 15:05 Thatoo

It does indeed seem like a mess. One thing to note is that Discord - another electron app -, used to have this problem and it has since been solved and screenshare works fine on the same computer, so I think it should be possible to solve. Shame they are closed source so we can't as easily figure out what they did to get it working.

maspling avatar May 20 '25 15:05 maspling

Well, this is just a lack of Wayland support in electron.

Well, indeed, this is just a lack of Wayland support in Chromium

Electron does support this. See my comment above.

When running in element web in Chrome, screen share works too.

So, it seems something's wrong in element itself...

luisfpg avatar May 22 '25 22:05 luisfpg

Discord and Chrome are prorpietary, they then might have added code to Chromium/Electron that we can't be aware of, so your comment doesn't really help, pure Chromium and pure Electron app (such as Jitsi or Element) have this issue. And we can't hope for Google to help Chromium/Electron as they would say that it does work with Chrome.

A move that would solve this issue and others might be to move from Electron to Tauri : https://github.com/element-hq/element-desktop/issues/771

Thatoo avatar May 23 '25 10:05 Thatoo

Discord and Chrome are prorpietary, they then might have added code to Chromium/Electron that we can't be aware of, so your comment doesn't really help, pure Chromium and pure Electron app (such as Jitsi or Element) have this issue. And we can't hope for Google to help Chromium/Electron as they would say that it does work with Chrome.

A move that would solve this issue and others might be to move from Electron to Tauri : #771

I tried screensharing under Chromium Version 136.0.7103.113 with the command chromium --enable-features=UseOzonePlatform --ozone-platform=wayland and it did work. Or am I misunderstanding something?

Obamium69 avatar May 23 '25 10:05 Obamium69

Discord and Chrome are prorpietary, they then might have added code to Chromium/Electron that we can't be aware of, so your comment doesn't really help, pure Chromium and pure Electron app (such as Jitsi or Element) have this issue. And we can't hope for Google to help Chromium/Electron as they would say that it does work with Chrome.

A move that would solve this issue and others might be to move from Electron to Tauri : #771

I don't understand why you say Chromium doesn't support screen share under Wayland. It does. @Obamium69 has already tested it. I also tested with no extra flags, and it works:

Image

Also, here's a screenshot of a simple electron app (the same I mentioned in my first comment) which shows a simple Electron app sharing screen under the same system:

Image

So, I still think this is an issue with element-desktop. Perhaps there's a combination of factors triggering the issue...

PS: I'm running Manjaro Linux with Plasma under Wayland.

luisfpg avatar May 23 '25 12:05 luisfpg

I'm not saying there is issue with screen sharing under wayland with electron app and Chromium. We are saying it, juste check how many people are complaining about it, please don't focus on me, I just report upstream issues : https://github.com/electron/electron/pull/35630#issuecomment-1254037947. https://issues.chromium.org/issues/40083534

Thatoo avatar May 23 '25 15:05 Thatoo

One easy way to compare different apps is via ferdium which is "electron with special tabs" https://github.com/ferdium/ferdium-app

You can try discord, teams, element, jitsi and what not in the same instance.

You will notice some will be able to share the screen while others won't. I have successfully used it for teams, jitsi and discord at least on wayland.

dal00 avatar May 23 '25 15:05 dal00

As a workaround for those (like me) which need screen share in Element and have already switched to Wayland: The main advantage of Element desktop over the web version is the system tray icon, which presents a badge indicating you have unread messages.

To bridge this, I've created a small project: https://github.com/luisfpg/element-tray. It shows a simple icon in the system tray, which gets updated (with a red badge) when the Element tab in the Chrome browser gets a new message (badge added), or when all messages are read (badge removed).

I don't plan to evolve the project much more than it currently is, but it might be useful for others. Once the screen sharing is properly supported in Element desktop under Wayland, this new project will be obsolete.

luisfpg avatar Jul 01 '25 16:07 luisfpg