[REQUEST] Unity WebGL Support for Photon Voice

edited July 27 in Photon Voice

Hello! I'd like to voice my request for Unity WebGL support for Photon Voice.

Support for WebGL is very technically possible (by creating a WebRTC mode), it is well worth adding, and the Photon stack is incomplete without this. There is an increase in users building for WebGL, using PUN and Fusion to make highly accessible multiplayer "metaverse" experiences (among other things), but Photon still has no voice support.

In order to get voice for my application, I must rely on using other companies' voice solutions and hooking them into PUN or Fusion, which is not ideal (most of these other solutions don't even have spatial audio support as they are most often used for Zoom-style video call apps). A WebRTC mode that supports WebGL would be extremely worthwhile to add.


  • Hi,

    Poor audio support for WebGL is a Unity problem first of all.

    We are working on an alternative but there is no ETA yet.

    Even if we implement WebGL audio capture and output, they won't be better than 3rd party solutions focused on audio. For instance, we do not provide spatial audio for other platforms but rely on Unity's AudioSource (which is not well suited for streaming in WebGL due to API limitations). Please do not expect us to implement 3d audio engine in WebGL. The best we can do is Zoom-style 2d output.

    Photon Voice is focused on data streaming and easy integration with 3rd party audio solutions. We provide platform-specific audio modules for convenience only.

    While the use of WebRTC is theoretically possible, we are not looking at it yet because its integration does not fit with the current Voice architecture.

  • Hi @vadim, thank you for your response!

    I'm aware there are technical challenges involved with audio when working with the WebGL platform, however the point of my post is to voice that it is certainly possible to do it and that it would be worth it for Photon to work through these challenges in order to have a complete product for WebGL users who are disappointed to find out that Photon Voice isn't supported.

    Although audio support inside Unity is challenging for WebGL, it should be possible to support full-spatial audio in WebGL by handling the audio on the javascript layer (outside of Unity), which can communicate with the Unity layer (https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html) to receive positions of voice audio sources & the audio listener and calculate spatial audio, which is essentially just a volume/gain and pan calculation. If interested, here is some example code for calculating spatial audio via pan and gain (scroll down to the "Update Spatial Audio" section): https://www.agora.io/en/blog/implementing-spatial-audio-chat-in-unity-using-agora/ Perhaps there's a better way to do it than I've mentioned, but all of this is just to say that it is possible to do it even though the architecture is different.

    Completely backing up from the technical stuff - If Photon's mission is to be a turnkey multiplayer solution for Unity ("we make multiplayer simple"), then from an end user perspective it totally makes sense for Photon Voice to support WebGL out of the box (as this is what Photon's users expect). Would you agree? If Photon does not have the in-house capabilities or resources to do this, then maybe Photon could partner with a 3rd party to either implement WebGL support within Photon Voice, or point to a fully-working voice integration by a 3rd party. Right now if a WebGL user lands on Photon's site, it's pretty unclear how they should go about implementing voice.

    I just wanted to voice my request for this, as it it's a feature that people want and have been asking about for a long time. :)

  • REM5_Studios
    edited July 27

    Hi @vadim, thank you for your reply!

    I’m aware that there are certain technical challenges involved with supporting WebGL. But really, the point of my post is to express that it is actually possible and that it would be great if Photon worked through these challenges in order to provide a complete multiplayer stack, with voice, for WebGL users (a segment that is growing).

    For example, instead of relying on Unity’s AudioSource, voice audio could be done on the JavaScript layer instead via JavaScript plugins (which can communicate with Unity to properly spatialize the audio). Spatial audio basically just comes down to calculating the volume and pan based on the voice position and the audio listener position. There’s a great article with code for exactly how to do it here (scroll down to the “Update Spatial Audio” section): https://www.agora.io/en/blog/implementing-spatial-audio-chat-in-unity-using-agora/ That calculation could be done in Unity (sending pan and gain info to the JavaScript layer) or that calculation could be done in the JavaScript layer (Unity sending the position of voice & audio listener to the JavaScript layer). Maybe there’s a better way to do it than this, but this is just one example of how that challenge could be overcome.

    You mention that we should not expect Photon to implement a 3D audio engine in WebGL and that the best you can do is 2D Zoom-style audio, but my opinion is that Photon should have a bit more confidence in this area. :) If Photon’s mission is to be a turnkey multiplayer solution for Unity (“we make multiplayer simple”), then it totally aligns with Photon’s mission to build voice support for WebGL out-of-the-box (which is what Photon's users expect and have been asking about for years). So, I just wanted to voice my request for that. Thanks!