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 · 46 comments
Open

WebRTC support on Linux #85

ken0x0a opened this issue May 30, 2020 · 46 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
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
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
Member

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

@nothingismagick
Copy link
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
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)

@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.

@JIGutierrez
Copy link

Have there been any workarounds discovered for this, specifically around P2P? I've been trying to use simple-peer on a Linux build, and haven't had any success with injecting webRTC packages, and I'd like to avoid changing protocols if possible...

Fingers crossed 🤞🏽

@DougAnderson444
Copy link

@JIGutierrez for my p2p tauri apps I use the WebRTC transport built into rust-libp2p

@JIGutierrez
Copy link

@JIGutierrez for my p2p tauri apps I use the WebRTC transport built into rust-libp2p

Right, but as far as I'm aware (new to Tauri and Rust) there's no way of using that JS-Side unless you create bindings for it, right?

@DougAnderson444
Copy link

What do you want to do exactly? Control your Rust WebRTC node from the JavaScript front end of Tauri? Relay Rust-Tauri WebRTC messages to the JS front end? Communicate with other WebRTC nodes (other people) from the JS front end of Tauri?

@JIGutierrez
Copy link

What do you want to do exactly? Control your Rust WebRTC node from the JavaScript front end of Tauri? Relay Rust-Tauri WebRTC messages to the JS front end? Communicate with other WebRTC nodes (other people) from the JS front end of Tauri?

I'd like to use the js library simple-peer, which uses the browser's WebRTC API, which is not in webgtk2 on Linux. You can optionally supply a custom webRTC implementation, but the only ones available are for Node and don't work on Tauri (as far as I've tried). I was considering compiling webrtc-rs to webassembly (haven't tried to know if it's compatible), but that does seem like overkill.

@matthme
Copy link

matthme commented Jun 18, 2024

You can indeed use simple-peer in the JavaScript front-end of your Tauri app for the browser client. That's no problem.

I think this is in fact exactly the problem this whole github issue is about, that this is not possible on Linux. I am no world-class systems builder however, so I might be dissecting the problem space along the wrong axes...

@bra1n
Copy link

bra1n commented Jul 17, 2024

The webkit devs compiled an entry in their FAQ for when WebRTC support arrives in Webkit and it links to this issue. So it seems like there is still some way to go before full WebRTC support arrives for Webkit and with that for Tauri on Linux.

@nyabinary
Copy link

So what the status with this and Tauri v2

@FabianLars
Copy link
Member

Still the same. Also, it's not coupled to the Tauri version (if we ignore tauri-apps/tauri#9662).

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