Search Unity

WebGL WebAssembly freezes on SceneManager.LoadScene(...)

Discussion in 'Web' started by benzuk, Sep 18, 2021.

  1. benzuk

    benzuk

    Joined:
    Mar 11, 2014
    Posts:
    117
    Hi,

    I'm working on my personal project and I have a few calls to SceneManager.LoadScene(...) and the game just freezes (crashes) after I want to load some scene.

    I think maybe it's because I have a few methods that do async operation:

    Code (CSharp):
    1.  
    2. private async void OnDestroy()
    3. {
    4.        if (webSocket != null)
    5.        {
    6.            await webSocket.Close();
    7.        }
    8. }
    9.  
    Is it can be because of that? if yes, can someone please explain me why? Unity engine shouldn't take care of it?

    Unity version: 2020.2.1f1

    Thanks,
    Ben
     
  2. benzuk

    benzuk

    Joined:
    Mar 11, 2014
    Posts:
    117
    So I found the issue, the issue is the NativeWebSocket library that I'm using throws an exception when websocket.Close() called and the connection was already closed, and in a result of that WebGL crashed.

    Anyways, I'd like to know if async/await is possible today on WebGL or will be possible in the future, thanks! :)