-
Notifications
You must be signed in to change notification settings - Fork 15k
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
fix: use StartUpdating method for PipeWire capturer #38833
Conversation
💖 Thanks for opening this pull request! 💖 We use semantic commit messages to streamline the release process. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
0c32734
to
ec7bb90
Compare
With this PR applied, it crashes somewhere else.
Before:
|
@byquanton Can you share the following information?
|
|
@byquanton I have no idea what Element is doing and its code base is too large to debug. However, the crash message that you're seeing is expected if you don't apply the updated |
I pushed a commit to fix thumbnail generation. I've validated the fixes using a more extensive test case that lists sources, displays thumbnails and initiates a stream using the source ID: https://gist.github.com/aiddya/d368bc2cb7f72a9b030b918ee1332299 |
Rebuild it again, and now it works. |
Hey @ckerr and @VerteDinde, has one of you had a chance to look into this PR? Screen sharing is currently broken when using Linux/Wayland on Element, Jitsi and Signal which is affecting thousands is not millions of users. Sending love to the universe… looking forward to a fix. 🙏 |
This also affects https://github.com/SpacingBat3/WebCord with 35K installs from pi-apps alone with thousands more from other avenues. I agree this is likely affecting millions of users/application installs. |
This also affects Armcord and Vencord Desktop. Which are both Linux focused Discord Clients. |
@aiddya Thanks for the PR! Sorry, I was out of the office when you submitted the PR originally, I'll take a look at it this week 🙇♀️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
have_selection_ = false; | ||
|
||
// PipeWire returns a single source, so index is not relevant. | ||
std::move(this->update_callback_).Run(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new logic applies cross-platform, though - is there a situation where we'd need this index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not unless Chromium makes significant changes/refactors. PipeWire is the only delegated capturer right now. As a result, this code path will not be executed on other platforms.
Secondly, according to Chromium documentation, delegated capturers manage their own UI for source selection and will return a single source. This logic should hold even if there's a new delegated capturer in the future.
c769e9a
to
747579c
Compare
Fixed a crash related to PipeWire capturer by adapting to Chromium's interface changes. Chromium expects a call to `NativeDesktopMediaList::StartUpdating` with an implementation of `DesktopMediaListObserver` for delegated capturers like PipeWire. This interface allows listening to user permission events and listing sources only after the user has made a choice on the permission dialog. The interface has been implemented by an inner class to allow listening to screen and window capture permissions concurrently using two instances of the class. A patch that was resetting the capturer on the first refresh has been changed to exclude PipeWire. PipeWire capturer object will follow the lifecycle of `NativeDesktopMediaList`, as is the case in Chromium. Fixes electron#37463
The PipeWire stream starts after the dialog is dismissed. If the sources are listed immediately afterwards, the thumbnail may not have been generated by that time. Explicitly wait for both thumbnail generation and a selection on the source dialog before listing sources.
Hey! Are others experiencing following issues on Ubuntu 22.04.1 LTS (or equivalent) and Electron 25.3.0 (which implements this PR)? First, calling const sources = await desktopCapturer.getSources({
types: ["window"],
}) Then, calling const constraints = {
audio: false,
video: {
mandatory: {
chromeMediaSource: "desktop",
chromeMediaSourceId: sourceId, // Source ID from `sources`
maxFrameRate: 24,
},
},
}
}
await navigator.mediaDevices.getUserMedia(constraints) This is pretty bad for user experience… and wasn’t the case on previous “working” versions of Electron (running on Ubuntu 22.04.1 LTS). Second, when window is selected, moving app window causes app to crash with following error. Dropping DMA-BUF modifier: 72057594037927935 and trying to renegotiate stream parameters
Segmentation fault (core dumped) Third (niche use case), implementation is completely broken on Tails 5.15.1. Puzzled… |
@sunknudsen i think you are talking about the same thing that was mentioned in this very same PR earlier. There already is the Issue #39043 for resolving this bad experience stuff. |
@ToasterUwU Did you experience segmentation fault during testing? |
@sunknudsen I have only tried it once for testing if it fixed the screenshare issue on a Discord Client, have not checked if it actually spits any errors while running. You can see the entire 40 second video i recorded of me trying it in Vencord/Vesktop#40, just so you know what exactly i did. It worked for me, even tho it was tedious to use. So if there was an error, it wasnt a fatal one (like Segmentation Fault typically is). Im on PikaOS 23.04, which is Ubuntu based. |
@sunknudsen You should not see the second popup if the portal implementation you're using supports screencast restoration. That's supported by xdg-desktop-portal 1.12 and xdg-desktop-portal-gnome 42. I tested moving and resizing the shared window with Electron 25.3.0, but I haven't seen any crash on Fedora 38. Do you see any of these issues on Chrome/Chromium? You can test using Mozilla's gUM example page. |
Hey @aiddya and @VerteDinde, thanks for helping out… please see #39131. Ideas? |
* fix: use StartUpdating method for PipeWire capturer Fixed a crash related to PipeWire capturer by adapting to Chromium's interface changes. Chromium expects a call to `NativeDesktopMediaList::StartUpdating` with an implementation of `DesktopMediaListObserver` for delegated capturers like PipeWire. This interface allows listening to user permission events and listing sources only after the user has made a choice on the permission dialog. The interface has been implemented by an inner class to allow listening to screen and window capture permissions concurrently using two instances of the class. A patch that was resetting the capturer on the first refresh has been changed to exclude PipeWire. PipeWire capturer object will follow the lifecycle of `NativeDesktopMediaList`, as is the case in Chromium. Fixes electron#37463 * fix: wait for thumbnails from PipeWire when necessary The PipeWire stream starts after the dialog is dismissed. If the sources are listed immediately afterwards, the thumbnail may not have been generated by that time. Explicitly wait for both thumbnail generation and a selection on the source dialog before listing sources.
Description of Change
Fixed a crash related to PipeWire capturer by adapting to Chromium's interface changes. Chromium expects a call to
NativeDesktopMediaList::StartUpdating
with an implementation ofDesktopMediaListObserver
for delegated capturers like PipeWire. This interface allows listening to user permission events and listing sources only after the user has made a choice on the permission dialog.The interface has been implemented by an inner class to allow listening to screen and window capture permissions concurrently using two instances of the class. A patch that was resetting the capturer on the first refresh has been changed to exclude PipeWire. PipeWire capturer object will follow the lifecycle of
NativeDesktopMediaList
, as is the case in Chromium.Fixes #37463
Checklist
npm test
passesRelease Notes
Notes: Fixed a crash when listing desktop capture sources on Wayland with PipeWire.