heroiclabs / nakama-unity

Unity client for Nakama server.
https://heroiclabs.com/docs/unity-client-guide
Other
411 stars 75 forks source link

WebGL builds fail when calling any Nakama method #117

Closed Meneleus closed 3 years ago

Meneleus commented 3 years ago

Add this to a gameobject in an empty project with Nakama installed:

using UnityEngine;
using Nakama;

public class TestNakama : MonoBehaviour {
    private IClient client;
    private ISession session;

    public async void Start() {
        client = new Client("http", "127.0.0.1", 7350, "defaultkey", UnityWebRequestAdapter.Instance) {
            Timeout = 5
        };

        try {
            session = await client.AuthenticateDeviceAsync("ABCXYZ12345", null, false);
            Debug.Log("OK");
        } catch (ApiResponseException e) {
            Debug.LogError(e.Message);
        }
    }
}

This should fail the Authentication, but instead complains about missing DLL (libc): DllNotFoundException: Unable to load DLL 'libc'. Tried the load the following dynamic libraries:

Stack trace:

 at System.Net.NetworkInformation.CommonUnixIPGlobalProperties.getdomainname (System.Byte[] name, System.Int32 len) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.NetworkInformation.CommonUnixIPGlobalProperties.get_DomainName () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.CookieContainer..ctor () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClientHandler.get_CookieContainer () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClientHandler.CreateWebRequest (System.Net.Http.HttpRequestMessage request) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClientHandler+<SendAsync>d__65.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClientHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpMessageInvoker.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClient.<>n__0 (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>d__47.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClient.SendAsync (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.Http.HttpClient.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x00000] in <00000000000000000000000000000000>:0 
  at Nakama.HttpRequestAdapter+<SendAsync>d__6.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0 
  at Nakama.HttpRequestAdapter.SendAsync (System.String method, System.Uri uri, System.Collections.Generic.IDictionary`2[TKey,TValue] headers, System.Byte[] body, System.Int32 timeout) [0x00000] in <00000000000000000000000000000000>:0 
  at Nakama.ApiClient+<AuthenticateEmailAsync>d__13.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
lugehorsam commented 3 years ago

Thanks @Meneleus for filing this issue. I think we can solve this by making the .NET HTTP client an optional dependency so that it's not shipped in a Unity codebase if the UnityWebRequest adapter is used.

Meneleus commented 3 years ago

Error is still present with 2020.3.14f1

Meneleus commented 3 years ago

Is that something I can do? Or is that to do with your build?

lugehorsam commented 3 years ago

@Meneleus it's something we need to do.

Meneleus commented 3 years ago

@lugehorsam đź‘Ť

Meneleus commented 3 years ago

I just confirmed the error is still present in 2019.4.28f1.

JalfResi commented 3 years ago

Any idea when this issue might be resolved - I have a build that only targets WebGL which fails with this issue. Is there a work around in the meantime?

novabyte commented 3 years ago

@JalfResi We're trying to resolve it at the moment. The problem is somewhere in the Unity WebGL compilation process. Can you let me know whether you pull in the Nakama asset via the Unity package manager, Unity Asset Store, or via a package install?

JalfResi commented 3 years ago

I got the nakama client from the unity store (via the web site) then installed it using the package manager.

novabyte commented 3 years ago

@JalfResi My current working theory is that the problem with WebGL builds is related to the way the code is included for it from the Unity package manager. Please can you use the asset from our releases page and see if you still have problems with your WebGL build?

JalfResi commented 3 years ago

The github releases page?

JalfResi commented 3 years ago

Okay, did that (used the sourcecode release to install the package.json using package manager). Got the following errors this time running in the browser:

exception thrown: InternalError: too much recursion,invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334601 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 invoke_ii@http://localhost:8081/Build/wargamed.framework.js:2:334556 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26844]:0x995bc1 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26883]:0x99758b @http://localhost:8081/Build/wargamed.wasm:wasm-function[26882]:0x997564 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26810]:0x994401 @http://localhost:8081/Build/wargamed.wasm:wasm-function[26845]:0x995f65 @http://localhost:8081/Build/wargamed.wasm:wasm-function[42592]:0xc8546d

unityFramework/Module.dynCall_ii@http://localhost:8081/Build/wargamed.framework.js:2:454933 wargamed.loader.js:1:4529 Uncaught InternalError: too much recursion invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2 invoke_ii http://localhost:8081/Build/wargamed.framework.js:2 dynCall_ii http://localhost:8081/Build/wargamed.framework.js:2

wargamed.framework.js:2:334601 31 wargamed.loader.js:1:4492 31 wargamed.loader.js:1:4529 printErr http://localhost:8081/Build/wargamed.loader.js:1 abort http://localhost:8081/Build/wargamed.framework.js:2

http://localhost:8081/Build/wargamed.wasm:13130421 http://localhost:8081/Build/wargamed.wasm:3706768 http://localhost:8081/Build/wargamed.wasm:13128980 dynCall_iiii http://localhost:8081/Build/wargamed.framework.js:2 keyEventHandlerFunc http://localhost:8081/Build/wargamed.framework.js:2 jsEventHandler http://localhost:8081/Build/wargamed.framework.js:2
JalfResi commented 3 years ago

Just tried this again and it appears to be working now. I'll investigate further (as I'm not seeing any indication that the rpc request has actually worked) but no errors for now

Meneleus commented 3 years ago

I have tried all 3 now. Installed from package manager, installed via package.json with source release and installed using the unity package from the release. They all give me the DLL error. Strange... the error is actually due to threads now?

Assertion failed: 0 && "Threads are not enabled for this platform.", file C:\Program Files\Unity\Hub\Editor\2020.3.14f1\Editor\Data\il2cpp\libil2cpp\os\Thread.cpp, line 412

Though this shows up too: DllNotFoundException: Unable to load DLL 'libc': The specified module could not be found.

Meneleus commented 3 years ago

Enabling threads crashes my unity.

using UntyEditor;
using UnityEngine;

[InitializeOnLoad]
class EnableThreads
{
    static EnableThreads()
    {
        PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
        PlayerSettings.WebGL.threadsSupport = true;
        PlayerSettings.WebGL.memorySize = 512;
    }
}

I'll keep trying things... :(

lugehorsam commented 3 years ago

@Meneleus this is a bug with Unity seemingly trying to insert the HTTPClient into network requests even though you are clearly passing the UnityWebRequestAdapter.

We've filed the issue here: https://fogbugz.unity3d.com/default.asp?1353899_0in8b9622uudgbni

Meneleus commented 3 years ago

Enabling threads crashes my unity.

using UntyEditor;
using UnityEngine;

[InitializeOnLoad]
class EnableThreads
{
    static EnableThreads()
    {
        PlayerSettings.WebGL.linkerTarget = WebGLLinkerTarget.Wasm;
        PlayerSettings.WebGL.threadsSupport = true;
        PlayerSettings.WebGL.memorySize = 512;
    }
}

I'll keep trying things... :(

https://fogbugz.unity3d.com/default.asp?1270915_kjsf2i72j3ufq15o

Sigh... I guess WebGL is just not going to happen for me.

lugehorsam commented 3 years ago

@Meneleus let's wait for a response from Unity on the issue we filed. You shouldn't need to enable threads, the root issue from our perspective is that Unity is injecting an Http client that requires threading into WebGL builds to begin with.

JalfResi commented 3 years ago

Just an update - finally got time to look into this, and yup it is failing still:

To use dlopen, you need to use Emscripten's linking support, see https://github.com/kripken/emscripten/wiki/Linking wargamed.loader.js:48:15 To use dlopen, you need to use Emscripten's linking support, see https://github.com/kripken/emscripten/wiki/Linking wargamed.loader.js:51:15 Invoking error handler due to abort("To use dlopen, you need to use Emscripten's linking support, see https://github.com/kripken/emscripten/wiki/Linking") at jsStackTrace@http://localhost:8081/wargamed/Build/wargamed.framework.js:739:12 stackTrace@http://localhost:8081/wargamed/Build/wargamed.framework.js:753:11 abort@http://localhost:8081/wargamed/Build/wargamed.framework.js:19:44 _dlopen@http://localhost:8081/wargamed/Build/wargamed.framework.js:9007:7 ZN6il2cpp2osL19LoadLibraryWithNameEPKci [il2cpp::os::LoadLibraryWithName(char const*, int)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[26205]:0x8fe57c ZN6il2cpp2os13LibraryLoader22LoadDynamicLibraryImplERKNS_5utils10StringViewIcEEi [il2cpp::os::LibraryLoader::LoadDynamicLibraryImpl(il2cpp::utils::StringView const&, int)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[26204]:0x8fe486 __ZN6il2cpp2os13LibraryLoader22LoadDynamicLibraryImplERKNS_5utils10StringViewIcEE [il2cpp::os::LibraryLoa… wargamed.loader.js:225:13

​

champilas commented 3 years ago

Hi everyone, hope you're doing great.

We are having the same issue with a webgl game that we are currently developing. I was searching in a lot of websites but this confirm to me that we need to use another multiplayer engine until Nakama team solve this because client is hurrying up and can't wait. This is very sad because Nakama is Great and works perfectly on other platforms!!!.

For now, i will be checking this forum everyday looking for good news.

Thank you guys of Nakama, you are great!

novabyte commented 3 years ago

@champilas Thanks for the kind words. It's a shame you cannot use Nakama right now because of this WebGL issue. It's not related to Nakama but some change in Unity Engine that we've not been able to source the origin of at this point.

The current theory is that its problematic because we moved to the Unity Package Manager format for the project layout which may have problems inside Unity with WebGL exports. We'll continue to investigate.

csdauth commented 3 years ago

Hello everyone!

Im having the same issue with the Webgl export and im too waiting for a fix to come out!

@novabyte If we download a previous Nakama release would the Webgl export work as expected? And if so which release should we download? Im asking this because you're saying the errors are possibly due to the current format. Guess it would make sense for a previous release to work?

Anyway, thanks for your support and your work.

lugehorsam commented 3 years ago

Hey everyone, we think we found a workaround for a bug in Unity's compiler toolchain that seems to be causing the problem here.

Before we release the potential fix we were wondering if any of you could test this on our experimental branch.

You can pull the branch into your Unity project with the following addition to your manifest.json:

"com.heroiclabs.nakama-unity": "https://github.com/heroiclabs/nakama-unity.git?path=/Packages/Nakama#luke/webgl-fix"

Meneleus commented 3 years ago

Trying it now

Meneleus commented 3 years ago

Looks like it's working. I was able to login. I'll try a match now.

EDIT - Perfect

Should I wait before publishing? It's not a production release, it's just for testing.

lugehorsam commented 3 years ago

@Meneleus we'll do a proper release tomorrow most likely.

Up to you if you want to release for internal testing. You'll be pulling in a debug .dll of the .NET library but other than that it should behave the same.

Thanks for testing!

Meneleus commented 3 years ago

Sounds good, I'll wait for the official release :thumbsup:

lugehorsam commented 3 years ago

Hey everyone, a new release is out that should fix this issue: https://github.com/heroiclabs/nakama-unity/releases/tag/v3.1.1

champilas commented 3 years ago

Ohhhh god! that was fast! Trying it now! Thank you guys, you are amazing.

champilas commented 3 years ago

Ok, i tried and worked good for me! Your are amazing, i wish i could help a little bit more. Thank you! you saved me.

I opened a new issue, because i found another problem with parties, if you can go and check there will be really helpful:

https://github.com/heroiclabs/nakama-unity/issues/119

Thank you again!!!

JalfResi commented 3 years ago

Not working for me I'm afraid!

An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was: abort("To use dlopen, you need to use Emscripten's linking support, see https://github.com/kripken/emscripten/wiki/Linking") at jsStackTrace@http://localhost:8081/wargamed/Build/wargamed.framework.js:739:12 stackTrace@http://localhost:8081/wargamed/Build/wargamed.framework.js:753:11 abort@http://localhost:8081/wargamed/Build/wargamed.framework.js:19:44 _dlopen@http://localhost:8081/wargamed/Build/wargamed.framework.js:9007:7 ZN6il2cpp2osL19LoadLibraryWithNameEPKci [il2cpp::os::LoadLibraryWithName(char const*, int)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[20043]:0x7dda7a ZN6il2cpp2os13LibraryLoader22LoadDynamicLibraryImplERKNS_5utils10StringViewIcEEi [il2cpp::os::LibraryLoader::LoadDynamicLibraryImpl(il2cpp::utils::StringView const&, int)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[20042]:0x7dd984 ZN6il2cpp2os13LibraryLoader22LoadDynamicLibraryImplERKNS_5utils10StringViewIcEE [il2cpp::os::LibraryLoader::LoadDynamicLibraryImpl(il2cpp::utils::StringView const&)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[20041]:0x7dd8cf __ZN6il2cpp2os13LibraryLoader18LoadDynamicLibraryENS_5utils10StringViewIcEEi [il2cpp::os::LibraryLoader::LoadDynamicLibrary(il2cpp::utils::StringView, int)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[20037]:0x7dd892 ZN6il2cpp2os13LibraryLoader18LoadDynamicLibraryENS_5utils10StringViewIcEE [il2cpp::os::LibraryLoader::LoadDynamicLibrary(il2cpp::utils::StringView)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[20036]:0x7dd883 ZN6il2cpp2vm14PlatformInvoke7ResolveERK16PInvokeArguments [il2cpp::vm::PlatformInvoke::Resolve(PInvokeArguments const&)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[22099]:0x820762 Z22il2cpp_codegen_resolveRK16PInvokeArguments [il2cpp_codegen_resolve(PInvokeArguments const&)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[23184]:0x844cc9 Z30il2cpp_codegen_resolve_pinvokeIPFiPhiELm5ELm14EET_RAT0KcRAT1S4_20Il2CppCallConvention13Il2CppCharSetib [int (il2cpp_codegen_resolve_pinvoke<int ()(unsigned char, int), 5ul, 14ul>(char const (&) [5ul], char const (&) [14ul], Il2CppCallConvention, Il2CppCharSet, int, bool))(unsigned char, int)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[35533]:0xa5ae9b _CommonUnixIPGlobalProperties_getdomainname_m986C881DC228C76FEDFE01DDA4375990B9F312F7@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[35532]:0xa5ae12 dynCall_iiii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43742]:0xc06863 unityFramework/Module.dynCall_iiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:24977:39 invoke_iiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:16120:17 _CommonUnixIPGlobalProperties_get_DomainName_m413AC21C8FCF33C473D3360DD83E0F9CFB7662D7@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[35534]:0xa5af18 ZN16VirtFuncInvoker0IiE6InvokeEtP12Il2CppObject [VirtFuncInvoker0::Invoke(unsigned short, Il2CppObject)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[19495]:0x7c8893 _CookieContainerctor_m50F677B7149D3D40B4D6ADB3DA9F27CF8434ECC2@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[35588]:0xa5df04 _HttpClientHandler_get_CookieContainer_m075BC107F7DB16F6CE788459B6AE6666C84A67B3@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29987]:0x962d6a _HttpClientHandler_CreateWebRequest_mD7DBEE29DEBC87263828A109121799ED67754EFC@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29991]:0x963076 ZN16VirtFuncInvoker1IP8String_tS1E6InvokeEtP12Il2CppObjectS1 [VirtFuncInvoker1<String_t, String_t>::Invoke(unsigned short, Il2CppObject, String_t)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[19708]:0x7d27d8 dynCall_iiii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43742]:0xc06863 unityFramework/Module.dynCall_iiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:24977:39 invoke_iiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:16120:17 _U3CSendAsyncU3Ed64_MoveNext_m021093E14BE1D37178D936AC1AF889DE2EADC319@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[30216]:0x96fef2 dynCall_vii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43839]:0xc07283 unityFramework/Module.dynCall_vii@http://localhost:8081/wargamed/Build/wargamed.framework.js:25462:38 invoke_vii@http://localhost:8081/wargamed/Build/wargamed.framework.js:17090:10 _AsyncTaskMethodBuilder_1_Start_TisU3CSendAsyncU3Ed__64_t57422588107F0FFBFE298AE1E2D447CAA0C52D15_mA5A525A9ADE3EA479CC74520E6810B9303EFA836_gshared@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[23414]:0x853884 Z138AsyncTaskMethodBuilder_1_Start_TisU3CSendAsyncU3Ed64_t57422588107F0FFBFE298AE1E2D447CAA0C52D15_m3EFDB057648EFB805D5BE50E3B1AF3D153E200D6P66AsyncTaskMethodBuilder_1_tC217217E692ABFDE23284B40EB5658083276E0C4P62U3CSendAsyncU3Ed64_t57422588107F0FFBFE298AE1E2D447CAA0C52D15PK10MethodInfo [AsyncTaskMethodBuilder_1_Start_TisU3CSendAsyncU3Ed__64_t57422588107F0FFBFE298AE1E2D447CAA0C52D15_m3EFDB057648EFB805D5BE50E3B1AF3D153E200D6(AsyncTaskMethodBuilder_1_tC217217E692ABFDE23284B40EB5658083276E0C4, U3CSendAsyncU3Ed64_t57422588107F0FFBFE298AE1E2D447CAA0C52D15, MethodInfo const)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[30025]:0x9646df _HttpClientHandler_SendAsync_mA9E0BE00809F23DBBD6859195230C495FB62E712@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[30024]:0x9646bd ZN16VirtFuncInvoker2IP48Task_1_tF08A4E047068CD6A9761693B04A791EC6BBF5F1AP60HttpRequestMessage_t2363952C1280568FCCFC6514257FA681811F942F59CancellationToken_tC9D68381C9164A4BA10397257E87ADC832AF5FFDE6InvokeEtP12Il2CppObjectS3S4 [VirtFuncInvoker2<Task_1_tF08A4E047068CD6A9761693B04A791EC6BBF5F1A, HttpRequestMessage_t2363952C1280568FCCFC6514257FA681811F942F, CancellationToken_tC9D68381C9164A4BA10397257E87ADC832AF5FFD>::Invoke(unsigned short, Il2CppObject, HttpRequestMessage_t2363952C1280568FCCFC6514257FA681811F942F, CancellationToken_tC9D68381C9164A4BA10397257E87ADC832AF5FFD)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29937]:0x960d90 _HttpMessageInvoker_SendAsync_m960414EBA1089801215BEE390E1BD82D872DA22D@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29981]:0x962bfd _HttpClient_U3CU3En0_mC92D5A3E1C733EB43862648282CF0CB4E2453A58@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29980]:0x962bb3 dynCall_iiiii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43750]:0xc0695b unityFramework/Module.dynCall_iiiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:25017:40 invoke_iiiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:16200:17 _U3CSendAsyncWorkerU3Ed__47_MoveNext_m83AA95946D2BCEC12F2A28C0E438819938ECC6C9@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[30209]:0x96f38f dynCall_vii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43839]:0xc07283 unityFramework/Module.dynCall_vii@http://localhost:8081/wargamed/Build/wargamed.framework.js:25462:38 invoke_vii@http://localhost:8081/wargamed/Build/wargamed.framework.js:17090:10 _AsyncTaskMethodBuilder_1_Start_TisU3CSendAsyncWorkerU3Ed47_t686731146ED17CA2309610B4CB385C73D6363C86_m4663BF03A534433DD3D1CBED629C0106D6857C58_gshared@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[23411]:0x853718 __Z144AsyncTaskMethodBuilder_1_Start_TisU3CSendAsyncWorkerU3Ed47_t686731146ED17CA2309610B4CB385C73D6363C86_mE1F8BA07E2D0FA09B29858EDBC5A4EEA9E08C516P66AsyncTaskMethodBuilder_1_tC217217E692ABFDE23284B40EB5658083276E0C4P68U3CSendAsyncWorkerU3Ed47_t686731146ED17CA2309610B4CB385C73D6363C86PK10MethodInfo [AsyncTaskMethodBuilder_1_Start_TisU3CSendAsyncWorkerU3Ed47_t686731146ED17CA2309610B4CB385C73D6363C86_mE1F8BA07E2D0FA09B29858EDBC5A4EEA9E08C516(AsyncTaskMethodBuilder_1_tC217217E692ABFDE23284B40EB5658083276E0C4*, U3CSendAsyncWorkerU3Ed47_t686731146ED17CA2309610B4CB385C73D6363C86, MethodInfo const)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29965]:0x961eed _HttpClient_SendAsyncWorker_mC45FA93F40093594D9791799B64639A0DCB0D7E0@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29964]:0x961ecb _HttpClient_SendAsync_mA306852835C84567599F0188221E47F096157F78@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29959]:0x961a39 _HttpClient_SendAsync_mF76A5061C70F7DFDA839E86B77B756496431F9AB@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29958]:0x9617a0 ZN16VirtFuncInvoker2IP48Task_1_tF08A4E047068CD6A9761693B04A791EC6BBF5F1AP60HttpRequestMessage_t2363952C1280568FCCFC6514257FA681811F942F59CancellationToken_tC9D68381C9164A4BA10397257E87ADC832AF5FFDE6InvokeEtP12Il2CppObjectS3S4 [VirtFuncInvoker2<Task_1_tF08A4E047068CD6A9761693B04A791EC6BBF5F1A, HttpRequestMessage_t2363952C1280568FCCFC6514257FA681811F942F, CancellationToken_tC9D68381C9164A4BA10397257E87ADC832AF5FFD>::Invoke(unsigned short, Il2CppObject, HttpRequestMessage_t2363952C1280568FCCFC6514257FA681811F942F, CancellationToken_tC9D68381C9164A4BA10397257E87ADC832AF5FFD)]@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[29937]:0x960d90 dynCall_iiiii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43750]:0xc0695b unityFramework/Module.dynCall_iiiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:25017:40 invoke_iiiii@http://localhost:8081/wargamed/Build/wargamed.framework.js:16200:17 _U3CSendAsyncU3Ed6_MoveNext_m161A42CC12D40362C837C0CCE35D1DD4D2516F9C@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[35882]:0xa72b20 dynCall_vii@http://localhost:8081/wargamed/Build/wargamed.wasm:wasm-function[43839]:0xc07

lugehorsam commented 3 years ago

@JalfResi are you using both the UnityWebRequestAdapter and the JsWebSocketAdapter as parameters to our Client and Socket objects, respectively? Those are both required for WebGL support.

If so, could you share when this error occurs? For example, is it when sending a socket message, authenticating, etc.?

JalfResi commented 3 years ago

This is the code I am using:

using System.Collections;
using System.Collections.Generic;
using Nakama;
using UnityEngine;

public class NakamaClient : MonoBehaviour
{

    private readonly IClient client = new Client("http", "127.0.0.1", 7350, "defaultkey");

    // Start is called before the first frame update
    async void Start()
    {
        const string email = "hello@example.com";
        const string password = "password";
        var session = await client.AuthenticateEmailAsync(email, password);
        Debug.Log(session);

        var payload = "{\"message\": \"Hello, world!\"}";
        var response = await client.RpcAsync(session, "go_echo_sample", payload);
        Debug.Log(response);
    }

    // Update is called once per frame
    void Update()
    {

    }
}
lugehorsam commented 3 years ago

@JalfResi thanks, please see our WebGL section in our README.md for code on how to use our client properly with Unity WebGL:

https://github.com/heroiclabs/nakama-unity#unity-webgl

JalfResi commented 3 years ago

Success! Thank you!