Does PUN2 support WebAssembly multi-threading?

Options
For those built without multithreading, PhotonNetwork.IsConnected became True and I was able to play the game.
The one set to multi-thread keeps waiting for PhotonNetwork.IsConnected, and after a while it will appear on the browser console
“Exiting receive thread (inside loop). Server: wss: //ns.exitgames.com: 19093: 0 Error: No status.”
Is output.
In UnityEditor, it works normally even if it is multi-threaded.

Do you support WebAssembly multi-threading?
Do I have to set anything for multi-threading?
The browser uses Google Chrome.

Best Answer

Answers

  • Tobias
    Options
    PUN does not explicitly support WebAssembly multi-threading. Means: We did not test this. For WebGl export, PUN uses a single threaded approach but your app may be multithreaded.

    Is this a stable feature in Unity already? Which version are you using?
  • ChoChick
    Options
    Use Unity 2019.2.5f1.
    Use PUN 2.15.

    Multithreading is enabled from the editor script.
    The Unity version I'm using doesn't seem to have an option to enable multithreading from ProjectSettings.
    I don't know if there is an option to enable multithreading in the new version of Unity.

    ----------
    using UnityEditor;
    using UnityEngine;

    [InitializeOnLoad]
    class EnableThreads
    {
    static EnableThreads()
    {
    PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
    PlayerSettings.WebGL.memorySize = 1024;

    // Enable multi-threading
    PlayerSettings.WebGL.threadsSupport = true;
    }
    }
    ----------
  • ChoChick
    Options
    I want to expect Unity to support WebAssembly multithreading.
    Thank you for your help.
  • chaarmi
    Options

    For anyone experiencing this issue => Exiting receive thread (inside loop). Server: XXXXX

    Here is the solutions that have worked for our team:

    1. Check to see if the scene that you are loading is not MASSIVE in size.
    2. Check to see if the scene being loaded is not sending/receiving data in the first frame (Wait a while before sending/receiving sync information with Photon).

    TO TEST AND SEE IF THIS IS THE CASE:

    1. Create a FULLY EMPTY dummy scene in unity and add it to the build settings
    2. Connect to Photon and try and use that EMPTY scene to see if works (Which it most likely should). This will alert you that your issue lies in the scene you were trying to load (Due to one of the above items OR something else in that specific scene).

    Hope the above solution helps out others going through the same issues!

    Nav Gupta => Former Unity 3D Live Help Expert Team Member and now Founder and CEO of Chaarmi Worlds Inc. making the future metaverse!! Check us out at Chaarmi.com!

  • Tobias
    Options

    Nice one! Thanks for the heads up.

    Thinking about it, yes loading a big scene could be a problem when there is only 1 thread. Hopefully that is a topic of the past in some time...