The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

No WebGL possible with PUN 2

Dufffit
2020-08-19 19:25:17

Hello everyone,

I am new to Photon/PUN and also quite new to unity. I have a problem using PUN 2 and could not find a solution up to now:

I just wanted to test if PUN 2 works also in WebGL Builds, as far as I know it should. But I am not able to get a working WebGL Build with PUN 2. I tried it also with the Demos (especially the SlotCar Demo) you can get with PUN (to be sure, that nothing in my Project creates the problem), but even then I can't get a working WebGL Build. When I build the Demo as Windows Standalone, everything works fine and I also can get a connection to the server from different clients.
When I want to build WebGL, I first got a build, but it never left the Unity/WebGL loading screen. And now after I updated Unity and PUN 2 to the current version I am not even able to get a build.

I give you a short history of what I tried:

When I open an empty unity (3D) project, I already get a warning:

Assembly for Assembly Definition File 'Packages/com.unity.collab-proxy/Tests/Editor/Unity.CollabProxy.EditorTests.asmdef' will not be compiled, because it has no scripts associated with it.  
UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterface:TickCompilationPipeline(EditorScriptCompilationOptions, BuildTargetGroup, BuildTarget, String[])  

after importing PUN 2, there are several warnings:

Unity is only able to load mdb or portable-pdb symbols. Assets/Photon/PhotonLibs/Metro/Photon3Unity3D.pdb is using a legacy pdb format.  
UnityEngine.Debug:LogWarning(Object)  
Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor:SyncIfNeeded(String[], String[], String[], String[], String[]) (at Library/PackageCache/[email protected]/Editor/VisualStudioEditor.cs:154)  
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

Unity is only able to load mdb or portable-pdb symbols. Assets/Photon/PhotonLibs/netstandard2.0/Photon3Unity3D.pdb is using a legacy pdb format.  
UnityEngine.Debug:LogWarning(Object)  
Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor:SyncIfNeeded(String[], String[], String[], String[], String[]) (at Library/PackageCache/[email protected]/Editor/VisualStudioEditor.cs:154)  
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

Unity is only able to load mdb or portable-pdb symbols. Assets/Photon/PhotonLibs/Photon3Unity3D.pdb is using a legacy pdb format.  
UnityEngine.Debug:LogWarning(Object)  
Microsoft.Unity.VisualStudio.Editor.VisualStudioEditor:SyncIfNeeded(String[], String[], String[], String[], String[]) (at Library/PackageCache/[email protected]/Editor/VisualStudioEditor.cs:154)  
UnityEditor.AssetPostprocessingInternal:PostprocessAllAssets(String[], String[], String[], String[], String[])

after loading the SlotCar Demo Scene, there is another warning:

Scene 'PunCockpit-Scene' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.  
To add a scene to the build settings use the menu File->Build Settings...  
UnityEngine.SceneManagement.SceneManager:LoadScene(String, LoadSceneMode)  
Photon.Pun.Demo.Cockpit.<Start>d__6:MoveNext() (at Assets/Photon/PhotonUnityNetworking/Demos/PunCockpit/Scripts/ThirdParty/PunCockpitEmbed.cs:53)  
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

If I build the Demo now as Windows Standalone, everything works fine despite the several warnings.

If I switch the platform to WebGL i get another 3 warnings:

Assets\Photon\PhotonRealtime\Code\PhotonPing.cs(449,17): warning CS0618: 'WWW' is obsolete: 'Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features'

Assets\Photon\PhotonRealtime\Code\PhotonPing.cs(456,35): warning CS0618: 'WWW' is obsolete: 'Use UnityWebRequest, a fully featured replacement which is more efficient and has additional features'

Assertion failed on expression: 'ins.second || ins.first->second == targetHash || (ins.first->second == CircularDependencyHash() && !targetHash.IsValid()) || GetPathFromAssetGuidV2(key.GetGUID()).ends_with(".cs")'  

now, if I click on "Build" I get another 4 messages:

Assets\Photon\PhotonLibs\WebSocket\WebSocket.cs(5,7): error CS0246: The type or namespace name 'WebSocketSharp' could not be found (are you missing a using directive or an assembly reference?)

Error building Player because scripts had compiler errors

Build completed with a result of 'Failed'  
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

UnityEditor.BuildPlayerWindow+BuildMethodException: 2 errors  
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x0027c] in <d1bec46880064709a5e713ad543e6d96>:0   
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <d1bec46880064709a5e713ad543e6d96>:0   
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Do you know what is wrong? Why is unity not even able to build the Demo of PUN 2 in WebGL?
As I already said I have the newest version of Unity and PUN 2.
I hope my request is not confusing or stupid.

Comments

Tobias
2020-08-20 11:03:59

PhotonLibs/netstandard2.0/Photon3Unity3D.pdb is using a legacy pdb format.

Funny. The lib was built with VS 2019 and recent SDKs.
Might be a bug of Unity to complain but it's just a warning. You just have no debug info.

The only real problem is that the export expects WebSocketSharp, which is definitely not used in WebGL exports.

The issue is the code "using WebSocketSharp;", which was added to the file WebSocket.cs. If you move it to line 9 (counted before the move), the export works again.

Sorry for the hassle.

Dufffit
2020-08-20 20:36:54

@Tobias wrote: »

...
The only real problem is that the export expects WebSocketSharp, which is definitely not used in WebGL exports.

The issue is the code "using WebSocketSharp;", which was added to the file WebSocket.cs. If you move it to line 9 (counted before the move), the export works again.
...

Thank you! That really helped. Now I am able to build the Demo in WebGL. But I am still not able to play. Unity tells me, that the Build succeeded.

Build completed with a result of 'Succeeded'  
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

But if I try to open it in my Browser (Firefox) I am stucked in the loading screen:

This happens also with Microsoft Edge.
Other WebGL Builds without PUN are running well.

OneManArmy
2020-08-20 21:25:43

If you use Mozilla, then press Ctrl + Shift + K to open console.

Dufffit
2020-08-20 23:24:27

I get this two Error messages:

Uncaught SyntaxError: illegal character webglbuild.framework.js.gz:1

Uncaught ReferenceError: unityFramework is not defined
onload file:///C://Photondemo/webglbuild/Build/webglbuild.loader.js:1
webglbuild.loader.js:1:3144
onload file:///C://Photondemo/webglbuild/Build/webglbuild.loader.js:1

Tobias
2020-08-21 15:15:18

This looks like an issue in the loader code. No idea why, this is Unity's domain.
A classic issue is a "space" in the path. Avoid that.

Maybe you check another Unity Editor version for the export?

Also import PUN into a new, empty project and export one of our demos (with the small fix discussed above. Let us know which Unity version you run.

Dufffit
2020-08-22 14:59:15

I tried it with 2020.1.2f1 and also 2020.1.0f1 before.

I also did the import into a new, empty project.

If the problem is Unity-wise I maybe try a complete reinstallation of Unity...

Dufffit
2020-08-23 15:57:32

I have an update:
I completely uninstalled Unity and installed the newest Version 2020.1.3f1.
The Slot Car Demo has the same Problem, BUT the Asteroid Demo works now witch WebGL (I did not test the other Demos up to now... a WebGL Build just takes too much time :D)

So it seems to be a problem of the Slot Car Demo and not a general PUN/Unity Problem. I will try to use it in my own projects now and hope that I can get it working.

Thanks for you efforts so far!

Tobias
2020-08-25 09:51:45

Please copy and paste the log of the SlotCar Demo. It should work in WebGL albeit showing an Error about not being able to load a scene. This should actually be Warning-level and not a concern.

It sounds as if WebGL builds should take place in 2019.4 instead of 2020.1...

Dufffit
2020-08-25 21:41:50

There are good news: Also the Slotcar Demo Scene works now. I don't know what I did wrong, but I just build it a again and now it works. So it seems reinstalling Unity and the WebSocketSharp fix helped.
Thanks for your effort again!

Tobias
2020-08-26 09:04:33

Thanks for your patience and providing feedback. Glad you're making progress again.

Back to top