Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Bug Updated lobby doesn't appear

Discussion in 'Lobby' started by Znimu, Apr 25, 2023.

  1. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    Hello,
    I meet an issue when I update a lobby: the lobby doesn't appear any more when I get the lobbies list.
    I followed the tutorial of CodeMonkey, and it works fine.

    But when I add:
    Code (CSharp):
    1. Lobby lobby = await Lobbies.Instance.UpdateLobbyAsync(joinedLobby.Id, new UpdateLobbyOptions {
    2.     Data = new Dictionary<string, DataObject> {
    3.         { "KEY_START_GAME", new DataObject(DataObject.VisibilityOptions.Member, relayCode)}
    4.     }
    5. });
    The lobby is not shown any more, but it still exists I think as I can get the relay code.

    I create the allocation just after the lobby creation, not sure if it can cause the issue.
     
  2. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    487
    How long after the creation do you update and how long after that do you get the lobby list?
     
  3. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    I update almost imediately after (I only create the relay before which is very fast).
    And the lobby list is displayed after that, just the time to click on a button so maybe 1-2 seconds.
     
  4. bartj-unity

    bartj-unity

    Unity Technologies

    Joined:
    Sep 9, 2021
    Posts:
    26
    Could you share your code for the lobby creation and the query as well (I'm assuming by "get the lobbies list", you mean query)?
     
  5. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    Sure.
    The entire function CreateLobby:

    Code (CSharp):
    1. try {
    2.             CreateLobbyOptions createLobbyOptions = new CreateLobbyOptions {
    3.                 IsPrivate = LobbyData.is_private,
    4.                 Player = GetPlayer(),
    5.                 Data = new Dictionary<string, DataObject> {
    6.                     { "GameMode", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.game_mode) },
    7.                     { "Map", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.game_map) },
    8.                     { "ModifierOutbreak", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_outbreak) },
    9.                     { "ModifierTiers1", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_tiers1) },
    10.                     { "ModifierBuildings", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_buildings) },
    11.                     { "ModifierStorm", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_storm) },
    12.                     { "ModifierRifle", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_rifle) },
    13.                     { "Modifier1Life", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_1life) },
    14.                     { "ModifierTraining", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_training_mode) },
    15.                     { "KEY_START_GAME", new DataObject(DataObject.VisibilityOptions.Member, "0") }
    16.                 }
    17.             };
    18.  
    19.             Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(LobbyData.game_description, LobbyData.max_players, createLobbyOptions);
    20.  
    21.             hostLobby = lobby;
    22.             joinedLobby = hostLobby;
    23.  
    24.             nb_players.text = (lobby.MaxPlayers - lobby.AvailableSlots) + " / " + lobby.MaxPlayers;
    25.  
    26.             lobby_code_input.GetComponent<TMP_InputField>().text = lobby.LobbyCode;
    27.  
    28.             Debug.Log("Create Lobby: " + lobby.Name + " (" + lobby.Id + ") map: " + lobby.Data["Map"].Value + " / " + lobby.Data["GameMode"].Value + " " + lobby.MaxPlayers + " - " + lobby.LobbyCode);
    29.  
    30.             DisplayPlayers();
    31.         } catch (LobbyServiceException e) {
    32.             Debug.Log(e);
    33.         }
    34.        
    35.         try {
    36.             string relayCode = await CreateRelay();
    37.  
    38.            Lobby lobby = await Lobbies.Instance.UpdateLobbyAsync(joinedLobby.Id, new UpdateLobbyOptions {
    39.                 Data = new Dictionary<string, DataObject> {
    40.                     { "KEY_START_GAME", new DataObject(DataObject.VisibilityOptions.Member, relayCode)}
    41.                 }
    42.             });
    43.  
    44.             joinedLobby = lobby;
    45.  
    46.             Debug.Log("Lobby relay code: " + lobby.Data["KEY_START_GAME"].Value);
    47.             Debug.Log("Relay code: " + relayCode);
    48.         } catch (LobbyServiceException e) {
    49.             Debug.Log(e);
    50.         }

    The function DisplayLobbies:

    Code (CSharp):
    1.  
    2.         try {
    3.             QueryLobbiesOptions queryLobbiesOptions = new QueryLobbiesOptions {
    4.                 Count = 25,
    5.                 Filters = new List<QueryFilter> {
    6.                     new QueryFilter(QueryFilter.FieldOptions.AvailableSlots, "0", QueryFilter.OpOptions.GT)
    7.                 },
    8.                 Order = new List<QueryOrder> {
    9.                     new QueryOrder(false, QueryOrder.FieldOptions.Created)
    10.                 }
    11.             };
    12.             QueryResponse queryResponse = await Lobbies.Instance.QueryLobbiesAsync(queryLobbiesOptions);
    13.  
    14.             nb_platoons_found.text = queryResponse.Results.Count.ToString();
    15.         } catch (LobbyServiceException e) {
    16.             Debug.Log(e);
    17.         }
    18.  
    If I comment the code in my first post above, it works well.

    I wonder if it could work to create the relay first. It would avoid a lobby update.
     
  6. bartj-unity

    bartj-unity

    Unity Technologies

    Joined:
    Sep 9, 2021
    Posts:
    26
    And just to clarify, is your
    LobbyData.is_private
    value false?

    You're right that you should be able to create the relay first, but in theory, the update you're making here doesn't seem like it should affect anything about the lobby showing up in queries.
     
  7. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    Yes, it is set to public (true).

    I will try that but it seems strange. Maybe it doesn't matter in most cases if people update the lobby just before to destroy it (as players go in the game) so it is probably not displayed. This is what CodeMonkey showed. But I want to display the regions in the lobby list host so I have to set Relay early.
     
  8. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    487
    If you set the
    IsPrivate
    variable to true, it will be set to private.
     
  9. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    Oh, I will check but it it must be false then ^^
    It was displayed before I add Relay and "public" was displayed on the lobby window.
     
  10. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    It is set to "false".

    However I forgot to mention that I get an error quite obscure sometimes. It seems related to Relay.
    I wanted to investigate later as it doesn't mean anything to me but maybe it is linked. I don't know.

    The error:

    Unable to find internal function `Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle::CheckWriteAndBumpSecondaryVersion_Injected`
    UnityEngine.StackTraceUtility:ExtractStackTrace ()
    Burst.Compiler.IL.Jit.JitBurstInitializeUtility:InvokeBurstInitializeFunction (intptr,string,intptr)
    Burst.Compiler.IL.Client.CompilerClient/LoadedLibrary:EnsureInitialized (intptr)
    Burst.Compiler.IL.Client.CompilerClient:CallCallback (Burst.Compiler.IL.Client.CompilerClient/RequestedFunctionPointer,Burst.Compiler.IL.Client.CompilerClient/LoadedFunctionPointer)
    Burst.Compiler.IL.Client.CompilerClient:HandleCompilationRequest (string,string[],Burst.Compiler.IL.Client.CompilerClientCompileStatusCallback,Burst.Compiler.IL.Jit.JitCompilerService/CompileCallbackDelegate,intptr,Burst.Compiler.IL.Jit.JitOptions,System.Nullable`1<Burst.Compiler.IL.Jit.FunctionPointerStub>)
    Burst.Compiler.IL.Jit.JitCompilerService:CompileInternal (string,string,intptr,Unity.Burst.NativeDumpFlags,intptr,intptr,string)
    Unity.Burst.BurstCompiler:Compile (object,System.Reflection.MethodInfo,bool,bool) (at Library/PackageCache/com.unity.burst@1.8.2/Runtime/BurstCompiler.cs:470)
    Unity.Burst.BurstCompiler:Compile (object,bool) (at Library/PackageCache/com.unity.burst@1.8.2/Runtime/BurstCompiler.cs:335)
    Unity.Burst.BurstCompiler:CompileFunctionPointer<Unity.Networking.Transport.NetworkProtocol/ComputePacketOverheadDelegate> (Unity.Networking.Transport.NetworkProtocol/ComputePacketOverheadDelegate) (at Library/PackageCache/com.unity.burst@1.8.2/Runtime/BurstCompiler.cs:317)
    Unity.Networking.Transport.TransportFunctionPointer`1<Unity.Networking.Transport.NetworkProtocol/ComputePacketOverheadDelegate>:.ctor (Unity.Networking.Transport.NetworkProtocol/ComputePacketOverheadDelegate) (at Library/PackageCache/com.unity.transport@1.3.3/Runtime/TransportFunctionPointer.cs:19)
    Unity.Networking.Transport.Relay.RelayNetworkProtocol:CreateProtocolInterface () (at Library/PackageCache/com.unity.transport@1.3.3/Runtime/Relay/RelayNetworkProtocol.cs:288)
    Unity.Networking.Transport.NetworkDriver:.ctor (Unity.Networking.Transport.INetworkInterface,Unity.Networking.Transport.INetworkProtocol,Unity.Networking.Transport.NetworkSettings) (at Library/PackageCache/com.unity.transport@1.3.3/Runtime/NetworkDriver.cs:728)
    Unity.Networking.Transport.NetworkDriver:.ctor (Unity.Networking.Transport.INetworkInterface,Unity.Networking.Transport.NetworkSettings) (at Library/PackageCache/com.unity.transport@1.3.3/Runtime/NetworkDriver.cs:648)
    Unity.Networking.Transport.NetworkDriver:Create (Unity.Networking.Transport.NetworkSettings) (at Library/PackageCache/com.unity.transport@1.3.3/Runtime/NetworkDriver.cs:572)
    Unity.Netcode.Transports.UTP.UnityTransport:CreateDriver (Unity.Netcode.Transports.UTP.UnityTransport,Unity.Networking.Transport.NetworkDriver&,Unity.Networking.Transport.NetworkPipeline&,Unity.Networking.Transport.NetworkPipeline&,Unity.Networking.Transport.NetworkPipeline&) (at Library/PackageCache/com.unity.netcode.gameobjects@1.3.1/Runtime/Transports/UTP/UnityTransport.cs:1566)
    Unity.Netcode.Transports.UTP.UnityTransport:InitDriver () (at Library/PackageCache/com.unity.netcode.gameobjects@1.3.1/Runtime/Transports/UTP/UnityTransport.cs:473)
    Unity.Netcode.Transports.UTP.UnityTransport:ServerBindAndListen (Unity.Networking.Transport.NetworkEndPoint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.3.1/Runtime/Transports/UTP/UnityTransport.cs:572)
    Unity.Netcode.Transports.UTP.UnityTransport:StartRelayServer () (at Library/PackageCache/com.unity.netcode.gameobjects@1.3.1/Runtime/Transports/UTP/UnityTransport.cs:703)
    Unity.Netcode.Transports.UTP.UnityTransport:StartServer () (at Library/PackageCache/com.unity.netcode.gameobjects@1.3.1/Runtime/Transports/UTP/UnityTransport.cs:1354)
    Unity.Netcode.NetworkManager:StartHost () (at Library/PackageCache/com.unity.netcode.gameobjects@1.3.1/Runtime/Core/NetworkManager.cs:1000)
    LobbiesController/<CreateRelay>d__52:MoveNext () (at Assets/MAIN MENU/Scripts/LOBBY/LobbiesController.cs:603)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<string>:SetResult (string)
    Unity.Services.Relay.WrappedRelayService/<GetJoinCodeAsync>d__7:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/SDK/WrappedRelayService.cs:131)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Relay.Response`1<Unity.Services.Relay.Models.JoinCodeResponseBody>>:SetResult (Unity.Services.Relay.Response`1<Unity.Services.Relay.Models.JoinCodeResponseBody>)
    Unity.Services.Relay.Apis.RelayAllocations.RelayAllocationsApiClient/<CreateJoincodeAsync>d__8:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Apis/RelayAllocationsApi.cs:160)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse)
    Unity.Services.Relay.Http.HttpClient/<MakeRequestAsync>d__1:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/HttpClient.cs:41)
    System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Relay.Http.HttpClientResponse>:SetResult (Unity.Services.Relay.Http.HttpClientResponse)
    Unity.Services.Relay.Http.HttpClient/<CreateWebRequestAsync>d__3:MoveNext () (at Library/PackageCache/com.unity.services.relay@1.0.5/Runtime/Http/HttpClient.cs:56)
    System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation:Run (System.Threading.Tasks.Task,bool)
    Sys
     
  11. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    Hello.

    I don't have any more the error above.
    And I now create the Relay before the Lobby, but the Lobby still doesn't appear with the query.

    The function to create the lobby is now:

    Code (CSharp):
    1. async public void CreateLobby()
    2.     {
    3.         string relayCode = await CreateRelay();
    4.         Debug.Log("Relay code: " + relayCode);
    5.  
    6.         try {
    7.             CreateLobbyOptions createLobbyOptions = new CreateLobbyOptions {
    8.                 IsPrivate = LobbyData.is_private,
    9.                 Player = GetPlayer(),
    10.                 Data = new Dictionary<string, DataObject> {
    11.                     { "GameMode", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.game_mode) },
    12.                     { "Map", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.game_map) },
    13.                     { "ModifierOutbreak", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_outbreak) },
    14.                     { "ModifierTiers1", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_tiers1) },
    15.                     { "ModifierBuildings", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_buildings) },
    16.                     { "ModifierStorm", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_storm) },
    17.                     { "ModifierRifle", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_rifle) },
    18.                     { "Modifier1Life", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_1life) },
    19.                     { "ModifierTraining", new DataObject(DataObject.VisibilityOptions.Public, LobbyData.modifier_training_mode) },
    20.                     { "KEY_START_GAME", new DataObject(DataObject.VisibilityOptions.Member, relayCode) }
    21.                 }
    22.             };
    23.  
    24.             Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(LobbyData.game_description, LobbyData.max_players, createLobbyOptions);
    25.  
    26.             hostLobby = lobby;
    27.             joinedLobby = hostLobby;
    28.  
    29.             nb_players.text = (lobby.MaxPlayers - lobby.AvailableSlots) + " / " + lobby.MaxPlayers;
    30.  
    31.             lobby_code_input.GetComponent<TMP_InputField>().text = lobby.LobbyCode;
    32.  
    33.             Debug.Log("Create Lobby: " + lobby.Name + " (" + lobby.Id + ") map: " + lobby.Data["Map"].Value + " / " + lobby.Data["GameMode"].Value + " " + lobby.MaxPlayers + " - " + lobby.LobbyCode);
    34.             Debug.Log("Lobby Relay code: " + lobby.Data["KEY_START_GAME"].Value);
    35.  
    36.             DisplayPlayers();
    37.         } catch (LobbyServiceException e) {
    38.             Debug.Log(e);
    39.         }
    40.     }
    Is there anything with Relay that could block? If I don't create the Relay, the lobby is displayed.
     
  12. veleek_unity

    veleek_unity

    Ben Randall Unity Technologies

    Joined:
    Aug 25, 2021
    Posts:
    59
    Can you submit a support request (using the Support link near the top of the page at https://dashboard.unity3d.com/lobby) so that we can get your org and project ids so we can troubleshoot this a little bit more. We don't see anything obvious wrong and we'd like to dig in.

    Can you also verify what value you're using for MaxPlayers?
     
  13. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    Sure.

    MaxPlayers is set to 11 or 3.
    Request sent.
     
  14. Znimu

    Znimu

    Joined:
    May 24, 2015
    Posts:
    19
    The error was on my side.
    Sorry.
    Thanks for the support.