Search Unity

Bug Authentication Hang

Discussion in 'Authentication' started by MousePods, Jan 30, 2023.

  1. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Hi,

    I might be misunderstanding something, but it seems like async isn't working? When I authenticate the user, my game freezes for around 2-3 seconds as it authenticated.

    1. Load in Scene
    2. On Scene Start - Authenticate User and also Play video

    Do I misunderstand async or is there a bug? Why when I authenticate the user does the video not play until the authentication is finished?

    Code (CSharp):
    1.  
    2.     private async void Start()
    3.     {
    4.         if(Utilities.CheckForInternetConnection())
    5.         {
    6.             await InitializeUnityServices();
    7.             await SignInUser();
    8.         }
    9.     }
    Code (CSharp):
    1.  
    2.     private async Task InitializeUnityServices()
    3.     {
    4.         InitializationOptions options = new InitializationOptions();
    5.  
    6.         #if UNITY_EDITOR || DEBUG_TOOLS
    7.         options.SetEnvironmentName("development");
    8.         #else
    9.         options.SetEnvironmentName("production");
    10.         #endif
    11.  
    12.         if(UnityServices.State == ServicesInitializationState.Uninitialized)
    13.         {
    14.             await UnityServices.InitializeAsync();
    15.         }
    16.     }
    17.  
    18.     private async Task SignInUser()
    19.     {
    20.         if(!AuthenticationService.Instance.IsSignedIn)
    21.         {
    22.             await AuthenticationService.Instance.SignInAnonymouslyAsync();
    23.         }
    24.     }
    Screenshot 2023-01-30 at 2.05.57 PM.png

    Thanks
     
    Last edited: Feb 18, 2023
  2. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Code (CSharp):
    1. Utilities.CheckForInternetConnection()
    is the issue as it is not async? It hangs for 2 to 3 seconds.

    Is this going to be fixed or is there a different method for checking if connected to the internet that is async.

    Thanks.
     
    Last edited: Feb 18, 2023
  3. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811
    Is there any insight into this?
     
  4. MousePods

    MousePods

    Joined:
    Jul 19, 2012
    Posts:
    811