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

WebRTC support on Linux #85

Open
ken0x0a opened this issue May 30, 2020 · 37 comments
Open

WebRTC support on Linux #85

ken0x0a opened this issue May 30, 2020 · 37 comments

Comments

@ken0x0a
Copy link

ken0x0a commented May 30, 2020

I tested only on macOS.
It might already work on other platforms.

Is your feature request related to a problem? Please describe.
I want to use WebRTC

Describe the solution you'd like
I don't have any preference.
I just want to use WebRTC.

Describe alternatives you've considered

  • With system webbrowser (doesn't work on macOS)
    Notification.requestPermission() // => undefined
    navigator.mediaDevices // => undefined
  • Using another process
    I don't know any library to use WebRTC with VideoUI on desktop 😭

Additional context

It seems, the cause of this issue is this https://forums.developer.apple.com/thread/88052

And, the following might solve this issue on macOS (not tested).
https://bugs.webkit.org/show_bug.cgi?id=208667#c17


There are similar issues in other repositories.

@nothingismagick
Copy link
Sponsor Member

So i found these additions to the Info.plist

	<key>NSCameraUsageDescription</key>
	<string>$(PRODUCT_NAME) Requires camera access in order to capture and transmit video</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>$(PRODUCT_NAME) Requires microphone access in order to capture and transmit audio</string>

https://developer.apple.com/documentation/bundleresources/information_property_list/nscamerausagedescription?language=objc
https://developer.apple.com/documentation/bundleresources/information_property_list/nsmicrophoneusagedescription?language=objc

@rajivshah3

@nothingismagick
Copy link
Sponsor Member

regarding notifications @ken0x0a - we merged a cross-platform notification API: tauri-apps/tauri#505

It will land in the next release.

@nothingismagick
Copy link
Sponsor Member

I am wondering if we will have to roll our own:
libp2p/rust-libp2p#1066

@nothingismagick
Copy link
Sponsor Member

Well, I believe that our new custom protocol allows for the secure context on all platforms. Still, we have not proven this to work, so am moving this issue over to WRY for tracking there.

@nothingismagick nothingismagick transferred this issue from tauri-apps/tauri Feb 27, 2021
@wusyong
Copy link
Member

wusyong commented Feb 27, 2021

Maybe this also belongs to #81?

@nklayman
Copy link
Member

WebRTC also is not supported by Webkit2GTK. It technically doesn't require permissions to work, but it's most commonly used with a webcam/mic input and those require permissions.

@wusyong wusyong added the help wanted Help is requested to fix this issue label Apr 17, 2021
@lemarier
Copy link
Member

lemarier commented Apr 20, 2021

macOS update

The runtime requires some permissions. Adding an embed PLIST to the runtime fixed the issue for me.

You can give it a try with embed_plist

Sample PLIST

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>NSCameraUsageDescription</key>
	<string>Request camera access for WebRTC</string>
	<key>NSMicrophoneUsageDescription</key>
	<string>Request microphone access for WebRTC</string>
</dict>
</plist>

Test app

#[cfg(target_os = "macos")]
embed_plist::embed_info_plist!("Info.plist");

fn main() -> wry::Result<()> {
  use wry::{
    application::{
      event::{Event, StartCause, WindowEvent},
      event_loop::{ControlFlow, EventLoop},
      window::WindowBuilder,
    },
    webview::WebViewBuilder,
  };

  let event_loop = EventLoop::new();
  let window = WindowBuilder::new()
    .with_title("Hello World")
    .build(&event_loop)
    .unwrap();
  let _webview = WebViewBuilder::new(window)
    .unwrap()
    .with_url("https://test.webrtc.org/")?
    .build()?;

  event_loop.run(move |event, _, control_flow| {
    *control_flow = ControlFlow::Poll;

    match event {
      Event::NewEvents(StartCause::Init) => println!("Wry application started!"),
      Event::WindowEvent {
        event: WindowEvent::CloseRequested,
        ..
      } => *control_flow = ControlFlow::Exit,
      _ => (),
    }
  });
}

Also, seems to works only over HTTPS, so doesn't work for custom protocol, so I think the wry job is pretty much done, only require the custom protocol support who I think should be moved to another issue.

Tauri should give the possibility to inject a PLIST at runtime for development. For bundled app, we already generate a plist, so maybe we should add it as a configuration object to request microphone, webcam access, so we could inject it automatically.

Edit: Looks like I've been able to get custom protocol to work. We need to make sure to use the host localhost in our custom protocol. So for example, instead of using wry:// as the entry point, we should use wry://localhost/, this way content, is processed as HTTPS.

@wusyong
Copy link
Member

wusyong commented Apr 27, 2021

It seems webkitgtk doesn't support webrtc.
https://bugs.webkit.org/show_bug.cgi?id=194805

@wusyong
Copy link
Member

wusyong commented Jun 29, 2021

Found a bug tracker states webkitgtk does has webrtc support.
https://bugs.webkit.org/show_bug.cgi?id=196222

I'll try to build it this night.

@nothingismagick
Copy link
Sponsor Member

Regarding boring-ssl and its gpl nature, we aren't shipping it (just linking) so it will not impact us.

@wusyong
Copy link
Member

wusyong commented Jun 29, 2021

yeah I think you are right. We cannot distribute it for non-GPL apps because of it.
Below is the status report from WPE but should hold the same to WebkitGtk
https://wpewebkit.org/about/faq.html#what%E2%80%99s-the-status-regarding-webrtc%3F

@wusyong wusyong changed the title WebRTC support WebRTC support on Linux Jun 29, 2021
@wusyong wusyong added platform: Linux and removed help wanted Help is requested to fix this issue platform: All labels Jun 29, 2021
@VarLad
Copy link

VarLad commented Nov 8, 2021

https://webrtc.rs/ seems usable now
Can that be somehow used for Tauri?

@YuilTripathee
Copy link

Is there any solution connecting other languages implementation like SWIG?
Seems like a workaround (but for temporary use might be usable)

@togetherwithasteria
Copy link

Hiiii ^^

Can we rename this issue to "WebRTC support on Unices"?

It seems this issue is also talking about MacOS (which isn't Linux of course), soo it'll be great for clarity!!!

@FabianLars
Copy link
Member

@lovelyyfiaaa Heyy :)
webrtc does work on macos, that's why the issue was renamed from WebRTC support to WebRTC support on Linux a few messages above (actually it was fixed a little bit before it was renamed)

@togetherwithasteria
Copy link

image

Ahh okay!! The codebase has no mention of it, so we should ask the devs first ^^

@togetherwithasteria
Copy link

I'm opening webrtc-rs/webrtc#231 nowww <3

@FabianLars
Copy link
Member

FabianLars commented Aug 3, 2022

I think a relevant issue for this would be: webrtc-rs/webrtc#94 and the crates linked in that, none of them seem to explicitly support pipewire.

Also, unless i got it completely wrong, this issue shows that it's not ready for tauri at all, which means we have to keep working for webkitgtk, buuut last time i checked, they planned on enabling the gstreamer backend in the 2.38 :)

@togetherwithasteria
Copy link

togetherwithasteria commented Aug 3, 2022

Regarding boring-ssl and its gpl nature, we aren't shipping it (just linking) so it will not impact us.

Ummm, I'm not a lawyer, buuut doesn't linking too trigger the GPL?

For proprieritary softwares, this is safe, as long as the company making the proprieritary part isn't hostile (for example Minecraft modders distribute mod patches and not the modified binaries), but this isn't the same case for crowd-enforced open source licenses right?

@togetherwithasteria
Copy link

Also, unless i got it completely wrong, this issue shows that it's not ready for tauri at all, which means we have to keep working for webkitgtk,

Yep!! There's RustAudio/cpal#554 but it seems it's not a finished issue yet?

@togetherwithasteria
Copy link

Umm, what do you guys think about using QtWebEngine?

@FabianLars
Copy link
Member

Umm, what do you guys think about using QtWebEngine?

tauri-apps/tauri#4554

@togetherwithasteria
Copy link

togetherwithasteria commented Aug 3, 2022

Aha, yup!!! There isn't a good bindings library for Qt in Rust yet for noww. ^^

@yuluo-zy
Copy link

Is WebRTC support available on Linux ?

@FabianLars
Copy link
Member

@yuluo-zy No, but we're somewhat optimistic that the next webkit2gtk version will add support for webrtc.

@FabianLars
Copy link
Member

Oh i forgot to update my above message - Yes, initial support was added in 2.38 but it's hidden behind a build flag and so far not a single distro enables it. Therefore we unfortunately have to keep waiting...

@zippy
Copy link

zippy commented Jan 3, 2023

Is there any action on this issue? I have just run into the same thing, and would really like this to work in Tauri.

@FabianLars
Copy link
Member

My last comment is still accurate. We're still waiting for the next webkigtk update which hopefully has more complete webrtc support. (they have a ~6 month release schedule to always get a new release out before a new ubuntu version in case you're wondering)

@DougAnderson444
Copy link

I am wondering if we will have to roll our own: libp2p/rust-libp2p#1066

WebRTC was merged into libp2p (for server-to-browser for now, which should "serve" Tauri's needs 😆) with this PR:

libp2p/rust-libp2p#2622 (Merged 🎉)

@luke-goddard
Copy link

Webkitgtk release note is a bit cryptic, can someone more informed than me confirm if WebRTC is supported with this release?
WebKitGTK 2.38.4 released! - Fix the build with GStreamer-based WebRTC enabled.

@FabianLars
Copy link
Member

Nope, it's hidden behind a (experimental?) build-time flag that no distro enabled so far, which means we have to wait for it to be stable and enabled by default on the webkitgtk side.

@edualb
Copy link

edualb commented Jun 18, 2023

@FabianLars do you have any update about this topic? Is there anything we (as community) can help with it?

@FabianLars
Copy link
Member

do you have any update about this topic?

Nothing specific, afaik it's making steady progress but i didn't see any hints about it being enabled by default in 2.42 yet (or any kind of ETAs for that matter).

Is there anything we (as community) can help with it?

People with experience in low-level stuff that may know a thing or two about anything that may help the webkitgtk project (whatever that would be) could reach out to the webkitgtk devs and see if they need any help.
Apart from that we can only really be patient.

@learncodingforweb

This comment was marked as spam.

@thenbe
Copy link

thenbe commented Feb 5, 2024

Instructions for how to enable webRTC on nixOS can be found in this thread. It's still a bit rough around the edges, but it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📬Proposal
Development

No branches or pull requests