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 wasm-ext #4229

Closed
Closed

Conversation

DougAnderson444
Copy link
Contributor

Description

Beginning of exploring an idea from @MarcoPolo about using the wasm-ext Transport with js-libp2p/webrtc imports in order to provide WebRTC through browser WebAssembly

Notes & open questions

I'm really not sure how well this will work, but worth a try to binding to the JS WebRTC browser code that is already working to the Rust library.

  • Currently I am stuck on how to implement StreamMuxer for the Connection and need some insight and direction from those who know it well.
  • Are the Transports going to be separated like they are in js-libp2p, for private and direct? I am assuming yes
  • This is a starting point for feedback, input and ideas from others to collab -- it is by no means ready (hence the draft status)

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@DougAnderson444
Copy link
Contributor Author

Currently stuck on impl libp2p_core::StreamMuxer for Connection and could use input on how to make it work (poll_inbound/outbound`):

https://github.com/DougAnderson444/rust-libp2p/blob/d9e6f155102a839df7638be7d11632403b777c67/transports/wasm-ext/src/lib.rs#L677

@thomaseizinger
Copy link
Contributor

thomaseizinger commented Jul 20, 2023

Even though the scope is a bit bigger, I think you'll be better off binding directly to the browser APIs using web-sys instead of pulling in all of js-libp2p.

I am worried that using js-libp2p in between creates way too many layers that are quite hard to debug.

We already have a webtransport impl that uses web-sys, I'd imagine that that would be quite a good starting point to do something similar for WebRTC! :)

@thomaseizinger
Copy link
Contributor

We consider wasm-ext to be deprecated and would like to move away from it for WebSockets as well but so far that isn't quite ready: #4102.

@DougAnderson444
Copy link
Contributor Author

Even though the scope is a bit bigger, I think you'll be better off binding directly to the browser APIs using web-sys instead of pulling in all of js-libp2p.

I had a feeling you were going to say that... but you are right, it's worth the extra effort in the long run.

We already have a webtransport impl that uses web-sys, I'd imagine that that would be quite a good starting point to do something similar for WebRTC! :)

I did see that indeed, I'll have a look and see if I've got the bandwidth to take a crack at it.

Are draft Pull Requests from a fork the preferred way to do these sorts of "build in public" work?

@thomaseizinger
Copy link
Contributor

We already have a webtransport impl that uses web-sys, I'd imagine that that would be quite a good starting point to do something similar for WebRTC! :)

I did see that indeed, I'll have a look and see if I've got the bandwidth to take a crack at it.

Are draft Pull Requests from a fork the preferred way to do these sorts of "build in public" work?

💯!

Much appreciated, thank you! :)

The API is the same as what js-libp2p interacts with so you should also be able to get some inspiration from there!

@DougAnderson444
Copy link
Contributor Author

Opened a WIP draft PR #4248 working towards web_sys bindings instead

mergify bot pushed a commit that referenced this pull request Sep 17, 2023
This PR implements `Transport` for WebRTC for browsers by using web-sys. Only the `webrtc-direct` spec is implemented. The `webrtc` spec for connecting two browsers with each other is left to a future PR.

Related: libp2p/specs#475.
Related #2617.
Supersedes: #4229.

Pull-Request: #4248.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
thomaseizinger added a commit that referenced this pull request Sep 21, 2023
This PR implements `Transport` for WebRTC for browsers by using web-sys. Only the `webrtc-direct` spec is implemented. The `webrtc` spec for connecting two browsers with each other is left to a future PR.

Related: libp2p/specs#475.
Related #2617.
Supersedes: #4229.

Pull-Request: #4248.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
@DougAnderson444 DougAnderson444 deleted the webrtc-wasm-ext branch November 29, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants