WebGL platform support

This thread is for describing the WebGL platform support of WebRTC technology. Currently, the WebGL platform is not supported.

Precondition
WebGL support has been advanced by external developers in Unity community.
Very thanks @nvanofwegen and @gtk2k

WebGL support is a long journey and we have many issues with merging it to the main branch. So I made the feature branch that receiving contributions from developers.

Current Status
We are reviewing the PR to merge the feature branch.
The related thread in the GitHub issue is here.

1 Like

Update 2022 February
The pull request above was merged into this feature branch on our repository.

Please feel free to try WebGL build using this branch. And post issues on this thread if you find, or make ticket on the GitHub Issues.

1 Like

Hello!

I’ve been testing the WebGL build for a small personal project, but I have ran into an issue, and I’m not sure whether its an problem with my setup or something else entirely.

I am currently using Windows 10, on Unity version 2020.3.27f1. I believe I am on the latest package version, 2.4.0-exp.5

Firstly, the way I installed the WebGL build was by manually editing the manifest.json file of my project so that the webrtc dependency looks as follows:

com.unity.webrtc": "https://github.com/Unity-Technologies/com.unity.webrtc.git#experimental/webgl-platform"
This seemed to install the right version, so I went ahead and setup a game controller object in an empty scene and added a script setting up a peer and opening a data channel like this:

Debug.Log("RTC config set up");
// Create local peer
Debug.Log("Creating local peer");
localPeer = new RTCPeerConnection(ref configuration);
localPeer.OnIceCandidate = localPeerOnIceCandidate;
localPeer.OnIceConnectionChange = localPeerOnIceConnectionChange;
localPeer.OnDataChannel = onDataChannel;
Debug.Log("Creating Data channel init");
RTCDataChannelInit conf = new RTCDataChannelInit();
Debug.Log("Creating Data channel");
localChannel = localPeer.CreateDataChannel("data", conf);

When I run this on a compiled WebGL build with a webserver, it seems to setup the peer and open the data channel with no problems. When I attempt to do this in the editor play mode though, Unity crashes, and the Editor.log reports the following:

Received signal SIGSEGV
Stack trace:
0x000002603034f819 (Mono JIT Code) (wrapper managed-to-native) Unity.WebRTC.NativeMethods:ContextCreateDataChannel (intptr,intptr,string,string)
0x000002603034f72b (Mono JIT Code) [Context.cs:211] Unity.WebRTC.Context:CreateDataChannel (intptr,string,Unity.WebRTC.RTCDataChannelInitInternal&)
0x000002603034f1f3 (Mono JIT Code) [RTCPeerConnection.cs:703] Unity.WebRTC.RTCPeerConnection:CreateDataChannel (string,Unity.WebRTC.RTCDataChannelInit)

I can still work on this thankfully, but I’d like to be able to test my code from the editor instead of having to wait for a build to finish. What should I do to resolve this? I have attached the editor log as a txt file to this post, please let me know if there is anything else I can provide. Thank you for your time!

7884949–1003285–Editor.txt (44.2 KB)

1 Like