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.
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.
0
Best Answer
-
For the time being, I would not bet on that feature:
"When enabled, Unity outputs a build with multithreading support. The generated content requires a browser that supports WebAssembly threads. This is an experimental feature and should only be used for testing purposes."
https://docs.unity3d.com/ScriptReference/PlayerSettings.WebGL-threadsSupport.html
At the moment, we don't have support for this on our roadmap. It will come at some point but right now, it's more for experiments.5
Answers
-
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?
0 -
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;
}
}
----------0 -
For the time being, I would not bet on that feature:
"When enabled, Unity outputs a build with multithreading support. The generated content requires a browser that supports WebAssembly threads. This is an experimental feature and should only be used for testing purposes."
https://docs.unity3d.com/ScriptReference/PlayerSettings.WebGL-threadsSupport.html
At the moment, we don't have support for this on our roadmap. It will come at some point but right now, it's more for experiments.5 -
I want to expect Unity to support WebAssembly multithreading.
Thank you for your help.0 -
For anyone experiencing this issue => Exiting receive thread (inside loop). Server: XXXXX
Here is the solutions that have worked for our team:
- Check to see if the scene that you are loading is not MASSIVE in size.
- 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:
- Create a FULLY EMPTY dummy scene in unity and add it to the build settings
- 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!
1 -
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...
0