WebRTC icon indicating copy to clipboard operation
WebRTC copied to clipboard

WebRTC package on visionOS

Open ChristophM2000 opened this issue 1 year ago • 10 comments

Hi,

Are there any plans to support visionOS with the WebRTC package?

Greetings, Christoph

ChristophM2000 avatar Nov 05 '24 15:11 ChristophM2000

I'm also interested. Meanwhile I will investigate how to build it from sources. Is there a specific reason to not add this like a technical roadblock?

pablott avatar Mar 13 '25 09:03 pablott

+1. Please make WebRTC available for all Apple platforms!

kevinmore avatar Mar 16 '25 12:03 kevinmore

For those who are interested, I am experimenting with this repo: https://github.com/because-why-not/webrtc_visionpro_workspace?tab=readme-ov-file It seems to me the project is not as mature as stasel's but it seems to work. I was able to compile the frameworks for both simulator and device and the Info.plist seems to be generated correctly. I was able to use it by manually importing the framework files into my project, import WebRTC and use it (in device). I need to do more testing but at first it seems to work well, WebRTC initializes and there were not crashes. It is also a concern that right now I can't use it as a package, but I think zipping the framework files and turning it into a Package.swift is possible (this would make it easier to distribute as a SDP package for development). Stasel's package follows this route.

pablott avatar Mar 17 '25 00:03 pablott

Another alternative is to use https://github.com/livekit/client-sdk-swift which does support visionOS. The WebRTC code is a patched version of Google's one. In my testing using LiveKit comes with its own issues. You are tied to their way of signaling. You are not forced to use their servers or pay for it but I want to be able to do a simple bootstrapping by passing a hardcoded SDP (or I wasn't able to find it). Perhaps you can just call the WebRTC part of the API. I was forced to use an external server to do the signaling, which is in theory doable if you set your own server to do the initial signaling but adds some setup effort.

pablott avatar Mar 17 '25 00:03 pablott

update: I no longer have the need to pass a hardcoded SDP (in fact, it is not very practical). Signaling is required, with WebRTC you can set it up with no STUN servers (as long as you can pass the local/remote SDP descriptions between devices in some way), but LiveKit seems to force a particular setup by using a server in between for the signaling (which may or may not be what you want). This is something to consider when choosing a solution.

pablott avatar Mar 24 '25 03:03 pablott

There's no need to pull in LiveKit's client SDK to use their webrtc port. Just use their webrtc package as a dependency: https://github.com/livekit/webrtc-xcframework

However, all their symbols are prefixed by "LK". Seems to work fine other than that? That said, I'm also commenting to subscribe and show my interest in visionOS support in this package :)

nevyn avatar Apr 07 '25 09:04 nevyn

Correct, I realize after I wrote that that you can pull their WebRTC package using SDP.

pablott avatar Apr 07 '25 09:04 pablott

Interested here as well. @nevyn Nice! have you some sample code about using their webrtc package as a dependency? For me it's kind of pretty opaque... maybe even a link to some document of swift usage would be incredible.

HyroVitalyProtago avatar Jul 29 '25 14:07 HyroVitalyProtago

@HyroVitalyProtago

You can see how I depend on it here: https://github.com/alloverse/allonet2/blob/main/Package.swift#L41 // line 41 sets up the dependency to be downloaded https://github.com/alloverse/allonet2/blob/main/Package.swift#L63 // line 63 sets up the framework to be linked with my target

I then use it from my library allonet2, which is very far from how you would use it directly by a UI client. But perhaps it can give you some direction; for example, I've wrapped a few methods so that they can be async await-ed, for example here: https://github.com/alloverse/allonet2/blob/main/Sources/alloclient/UIWebRTCTransport.swift#L51

nevyn avatar Jul 30 '25 13:07 nevyn

@nevyn Thanks a lot! 🙏

HyroVitalyProtago avatar Jul 31 '25 08:07 HyroVitalyProtago