Skip to content

Conversation

@Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Nov 13, 2025

This adds support for screen sharing on Wayland (fixes #28754). I am not able to test on Windows and macOS, so I will need help testing those.

libwebrtc replaces scap, which aims to be cross platform but was only used on Windows and X11. The X11 support relied on an out-of-tree branch on which the original author closed their own pull request (CapSoftware/scap#124). This also replaces Zed's platform-specific code on macOS. Switching to a single cross platform library simplifies the code by removing the need for Zed to have its own traits for cross platform abstraction.

This uses my branch of the Livekit Rust SDK. This branch merges several pull requests I have awaiting review upstream:

Currently, the webrtc-sys crate from Livekit downloads a prebuilt static libwebrtc C++ library (which is a nonstarter for Linux distro packagers). This branch requires changes to how the C++ library is built. Because those changes in livekit/rust-sdks#725 have not yet been merged upstream, you must build libwebrtc from source to build this branch on Linux. My Livekit branch will build libwebrtc from source during the Cargo build if you set the LK_LIBWEBRTC_SOURCE environment variable to the absolute path of an archive of the libwebrtc source code. In my Livekit branch, there is a script to generate this source code archive, which you can do by running:

git clone https://github.com/Be-ing/rust-sdks.git -b zed
cd rust-sdks/webrtc-sys/libwebrtc/
./generate-source-archive.sh

This script takes a long time to run because libwebrtc is developed as part of Chromium. Thus, it requires downloading about 9 GB of junk that isn't needed for libwebrtc. The generate-source-archive.sh script removes a bunch of that junk to strip it down to a 125 MB .tar.xz archive, which I hope will be published upstream by Livekit when my PRs are reviewed and merged.

Release Notes:

  • Added screen sharing support on Wayland (Linux)

TODO:

  • Get all tests, examples, and collab server building
  • Upstream release of prebuilt libwebrtc C++ library
  • Rework screen selection GUI for Wayland
  • HELP WANTED: Update Nix's livekit-libwebrtc package
  • HELP WANTED: Test on Windows
  • HELP WANTED: Test on macOS

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 13, 2025
@maxdeviant maxdeviant changed the title use libwebrtc's DesktopCapturer for screen capture Use libwebrtc's DesktopCapturer for screen capture Nov 13, 2025
@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch from 0c5daae to b078823 Compare November 13, 2025 21:39
@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch from b078823 to 0e67b6b Compare November 13, 2025 21:44
@ConradIrwin
Copy link
Member

Nice! I'm very excited about fixing Wayland screen-sharing.

We'd definitely need the webrtc build caching stuff to merge this though... thanks for fighting with that.

Also looks like you removed the screen selector; is there an easy path to bring that back through webRTC's stuff?

@Be-ing
Copy link
Contributor Author

Be-ing commented Nov 14, 2025

We'd definitely need the webrtc build caching stuff to merge this though...

I split off the required build changes to a trivially small PR so it's easy for upstream to review that quickly: livekit/rust-sdks#784 (Edit: that has been merged, waiting on upstream to tag a new release)

thanks for fighting with that.

Yeah, that took several weeks of yak shaving before I could actually work on Zed. 🪒 My CPU is not super fast (Intel Core i7 8550U) so there was lots of waiting involved.

Also looks like you removed the screen selector; is there an easy path to bring that back through webRTC's stuff?

I have not removed that, though the existing GUI code will need some work because applications can't have their own UI for that on Wayland. The XDG Desktop Portal doesn't expose the available screens/windows to applications; libwebrtc returns a single dummy CaptureSource with an empty string for a title. When DesktopCapturer::start_capture is called, the XDG Desktop Portal presents its GUI for the user to choose the screen (and/or window if enabled).

@Be-ing
Copy link
Contributor Author

Be-ing commented Nov 17, 2025

I tested this on a call with my friend @NOTtheMessiah and he was able to see me sharing my screen from Wayland! 🎉

@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch 10 times, most recently from 0a1b90c to 7fbf32f Compare November 18, 2025 04:43
@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch 2 times, most recently from 54f4681 to 35b2a89 Compare November 19, 2025 00:23
@Be-ing
Copy link
Contributor Author

Be-ing commented Nov 19, 2025

CI builds are working now except for Nix. The livekit-libwebrtc Nix package needs to be updated to include the changes made to the build of upstream's prebuilt library: livekit/rust-sdks#784 and livekit/rust-sdks#787

@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch from 35b2a89 to 3bbfde2 Compare November 19, 2025 05:32
Comment on lines -530 to +522
children.push(
SplitButton::new(
trigger.render(window, cx),
self.render_screen_list().into_any_element(),
)
.style(SplitButtonStyle::Transparent)
.into_any_element(),
);
match room.available_screens().len() {
0 => (),
1 => children.push(trigger.into_any_element()),
2.. => children.push(
SplitButton::new(
trigger.render(window, cx),
self.render_screen_list().into_any_element(),
)
.style(SplitButtonStyle::Transparent)
.into_any_element(),
),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the title bar to not show the menu for screen selection when there is only one screen. This avoids a confusing situation on Wayland because libwebrtc only returns a single CaptureSource with an empty string for a title, which looked like this:

image

Applications can't choose the screen to share on Wayland. Instead, the XDG Desktop Portal presents a GUI for the user to select the screen without the application knowing which screen was picked.

The list of available screens is refreshed when joining a call, so if a screen is added while Zed is running, it can be shared by leaving and rejoining the call without having to restart Zed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of available screens is refreshed when joining a call, so if a screen is added while Zed is running, it can be shared by leaving and rejoining the call without having to restart Zed.

I have improved this to refresh the list of screens when sharing and unsharing a screen. This way, if a screen is plugged in during a call, sharing it doesn't even require leaving the call.

@Be-ing
Copy link
Contributor Author

Be-ing commented Nov 19, 2025

@mikayla-maki @ConradIrwin Could we test this on a call with you on macOS or Windows? I've invited you to a #libwebrtc-screenshare channel I created. Alternatively, you could invite me to one of Zed's channels and give me permission to screenshare there.

@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch 6 times, most recently from 80772a2 to bf05695 Compare November 19, 2025 20:20
@ConradIrwin
Copy link
Member

@Be-ing great! Happy to help out, are you able to book time here: https://cal.com/conradirwin/pairing? then we can meet up and test things out.

I also tried to amplify your work with the people we know at Livekit, so I'm hoping we can make progress on the merging front too.

@Be-ing
Copy link
Contributor Author

Be-ing commented Nov 19, 2025

@Be-ing great! Happy to help out, are you able to book time here: https://cal.com/conradirwin/pairing? then we can meet up and test things out.

I booked for 1 PM US Central time this Friday.

I also tried to amplify your work with the people we know at Livekit, so I'm hoping we can make progress on the merging front too.

Much appreciated! They recently did 2 thorough reviews of livekit/rust-sdks#725 and all that's left there is fixing the Android builds (not relevant for Zed, but Livekit needs that to release).

@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch 12 times, most recently from 3e7ca46 to 3e96af3 Compare November 21, 2025 06:53
in buildInputs
@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch from 3e96af3 to 75e7b0b Compare November 21, 2025 16:24
This adds support for screen sharing on Wayland (fixes zed-industries#28754).

libwebrtc replaces scap, which aims to be cross platform but was only
used on Windows and X11. The X11 support relied on an out-of-tree branch
on which the original author closed their own pull request
(CapSoftware/scap#124). This also replaces Zed's
platform-specific code on macOS. Switching to a single cross platform
library simplifies the code by removing the need for Zed to have its own
traits for cross platform abstraction.
@Be-ing Be-ing force-pushed the libwebrtc_desktop_capture branch from 75e7b0b to 4d038c9 Compare November 21, 2025 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement community champion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't screenshare on Wayland (Linux)

6 participants