Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Official WebGL platform support

Discussion in 'Unity Render Streaming' started by kazuki_unity729, Jul 27, 2021.

  1. kazuki_unity729


    Unity Technologies

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

    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.
    M_MG_S likes this.
  2. kazuki_unity729


    Unity Technologies

    Aug 2, 2018
    M_MG_S likes this.
  3. Robocop278


    Oct 3, 2019

    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": ""

    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:
    Code (CSharp):
    1. Debug.Log("RTC config set up");
    2. // Create local peer
    3. Debug.Log("Creating local peer");
    4. localPeer = new RTCPeerConnection(ref configuration);
    5. localPeer.OnIceCandidate = localPeerOnIceCandidate;
    6. localPeer.OnIceConnectionChange = localPeerOnIceConnectionChange;
    7. localPeer.OnDataChannel = onDataChannel;
    8. Debug.Log("Creating Data channel init");
    9. RTCDataChannelInit conf = new RTCDataChannelInit();
    10. Debug.Log("Creating Data channel");
    11. 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:
    Code (CSharp):
    1. Received signal SIGSEGV
    2. Stack trace:
    3. 0x000002603034f819 (Mono JIT Code) (wrapper managed-to-native) Unity.WebRTC.NativeMethods:ContextCreateDataChannel (intptr,intptr,string,string)
    4. 0x000002603034f72b (Mono JIT Code) [Context.cs:211] Unity.WebRTC.Context:CreateDataChannel (intptr,string,Unity.WebRTC.RTCDataChannelInitInternal&)
    5. 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!

    Attached Files:

    anlun16 likes this.