InvalidOperationException: out of sync

Options
Many players are disconnected after they've got this error :
InvalidOperationException: out of sync
System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,ExitGames.Client.Photon.NCommand].VerifyState ()
System.Collections.Generic.Dictionary`2+Enumerator[System.Int32,ExitGames.Client.Photon.NCommand].MoveNext ()
System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[System.Int32,ExitGames.Client.Photon.NCommand].MoveNext ()
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
PhotonHandler.Update () (at Assets/Plugins/PhotonNetwork/PhotonHandler.cs:65)

Sometimes those errors occured just before the previous one :
Received unknown status code: QueueIncomingUnreliableWarning

Any idea of that can cause those problems ?

Comments

  • 2Kin
    Options
    After many investigations, I realized that if a player re-uses the same ViewID.ID in other rooms, his connexion will feels buggy (like in this message, or no trigger of OnPhotonSerializeView) and sometimes the error described before will finally occurs.
    I use Photon.Instantiate with PhotonNetwork.autoCleanUpPlayerObjects at true, so everything should be ok... but if I comment out this line (in NetworkingPeer.cs - line 279)...
    //this.allocatedIDs = new Dictionary<int, PhotonViewID>();
    
    ...everything come back to normal !

    I think there might be a problem with PhotonNetwork.UnAllocateViewID ?
  • Actually, I'm getting the same error after updating PUN from 1.15 to 1.16.2. My network scenario did not change since 1.15 and here it is:
    - In a lobbby scene player A creates a room and waits until PhotonNetwork.otherPlayers.Length > 0
    - In the lobby scene player B joins the room and waits until PhotonNetwork.otherPlayers.Length > 0
    - When PhotonNetwork.otherPlayers.Length > 0 is true both players do the following:
    [code2=csharp]PhotonNetwork.isMessageQueueRunning = false;
    Application.LoadLevel("Main scene");[/code2]
    - Inside the main scene there is a GO which has the following code:
    [code2=csharp]void Start()
    {
    photonView.RPC("OnRemoteGameStarted", PhotonTargets.Others, parameters);
    OpenNetworkMenu();
    PhotonNetwork.isMessageQueueRunning = true;
    }

    [RPC]
    protected void OnRemoteGameStarted()
    {
    CloseNetworkMenu();
    }[/code2]
    Closing network menu means actual game start. Unfortunately, out of sync error leads to a disconnection from the Cloud and this error occurs *very* often. Maybe someone will find a bug in my sync scenario, huh? Or maybe there is a workaround?
  • 2Kin
    Options
    Have you tried the solution I described in my above post ?
    It worked pretty well for me.
    Unfortunately if it work for you too, it just imply that there is a problem in PUN 1.16...
  • You mean commenting out the line "this.allocatedIDs = new Dictionary<int, PhotonViewID>();" in NetworkingPeer.cs? No, this did not help me :(
  • 2Kin
    Options
    I know I had some strange behaviours with isMessageQueueRunning.

    I discarded it, and instead I load my level (for me it is an assetbundle), and when it's ready, I join/create the room. When OnJoinedRoom is triggered, I instantiate my local player other the network, and wait OnMasterClientSwitched is triggered before sending any RPC's events.

    Also, I place OnMasterClientSwitched (and OnPhotonPlayerDisconnected/OnJoinedRoom/OnLeftRoom) in a "Scene's PhotonView" so it is always there listening to my "Photon's global events".
  • 2Kin, thanks for the insight, maybe it will workaround my troubles, need to try!
    BUT this scenario is definitely not the proper one since there is at least one awful drawback. When you postpone room join to the time of level has loaded a set of events might happen then:
    1) joining a room will not succeed because max room players reached while you were loading the level
    2) room creator has left the room while and it is already anavailable
    3) etc.
    I hope devs from Exit Games can add something to our discussion.
  • 2Kin
    Options
    You're right, it's definitely not the better solution, just a workaround I found for isMessageQueueRunning which cause me some troubles.
    Maybe if someone can emphasize with this, it will make thinks advance.
    But if it's just me who is totally wrong with isMessageQueueRunning, and if there is something else that has corrected my problem, well then : shame on me !
  • Tobias
    Options
    2Kin, sorry for the late reaction.
    The exception in the stacktrace is not a known one. I can't see how this happens in DispatchIncomingCommands().
    Can you share the reproduction steps and or a project? This would make it a lot easier to find. I also don't see yet, how it's related to UnAllocateViewID. Maybe you have more stuff in the log? Can you share the complete one?
    Which library version do you use?


    demid: I will try to check you scenario. Maybe this already helps.
  • 2Kin
    Options
    I've made many corrections since this problem occured, and I don't have a versioning system :(

    I can only tell that if I use PhotonNetwork.isMessageQueueRunning at false after I join/create a room and wait for my player instantiation (OnPhotonPlayerInstantiate) to set it at true, this error pop out and after that players are disconnected.
    Also, to comment line 279 in NetworkingPeer.cs solves problems where players don't dispatch there position via "OnPhotonSerialize" (and finally are disconnected after 2/10 minutes).

    Sorry if I'm not clear, but as nobody answer me (I'm not complaining !), well I tested differents configurations on my side before having the one that solved my problems...

    For my first "correction" I assumed there were some problems of bufferisation (as I load AssetBundle which are quite large -around 10Mo-). For the second one I assumed there was a problem with UnAllocateView... but that's just suppositions of someone who don't know very finely the system.

    Edit : noticed on PUN 1.16.2 (it might be cool if we can select it in a dropdown area when creating an new topic).
  • Tobias
    Options
    Ah, ok, so you could fix the issue and now it's difficult / impossible to reproduce.
    Not a problem. I will try to check this with what I have.
    Thanks for the info!
  • Tobias, maybe condition other than "PhotonNetwork.otherPlayers.Length > 0" is more safe to proceed with level loading? Or maybe I need to check this condition in other place rather than OnGUI()? Say, inside OnPhotonPlayerConnected()?
  • Tobias
    Options
    Looking at the error once more, it really look like a threading problem. These could happen in older PUN versions, as the client library was not thread safe and while loading a level, we have to use one extra Thread.
    I think the problem went away because you updated to PUN 1.16, which has a Thread safe library.

    The callback OnPhotonPlayerConnected is better to implement this. It's a rare event and should not be checked ever GUI frame.
  • 2Kin
    Options
    Today I've updated my game and I ran in the same issue.
    The only thing I changed about the network's part, was to set my PhotonView on "Unreliable"... when I set it back to "Reliable Delta Compress" the error disapeared.

    Edit : I'm awfully bad at reporting errors :oops:
  • Tobias, for now I only can declare that I use PUN 1.16.2 and the problem appeared with upgrade PUN 1.15 to 1.16.2.
    My Photon3Unity3D.dll has version 3.0.1.12. I tried to trigger load level via OnPhotonPlayerConnected() but without success, the same error prevents me rather often from starting a game.
  • Tobias, to be more specific, the way of level load triggering inside OnPhotonPlayerConnected() led to a new trouble: one client loads a level faster than another stops accepting messages from the opponent and it leads to an invalid RPC call to a nonexisting PhotonView. I suppose that the same error could occur in my previous network scenario but anyway this is realistic and I finally can not understand what is the best way to make both players start a game at the same time. Do you have a ready out-of-the-box scenario of synchronous level start for two (or more) players while they should initiate game start from the lobby scene?
  • friuns
    Options
    i get same error every second if there many players

    Tobias if you using dictionary there and foreach loop, this how to fix it
    http://forum.unity3d.com/threads/141447 ... -just-fine
  • Tobias
    Options
    I'm sorry for being absent for the last few days. I will take another look at this today.
    Thanks for the reports. If anyone could share a reproduction project, that would be even more awesome.
  • Tobias
    Options
    I think I found the cause for this and fixed it.
    Please check out the lib attached to this post and let me know if the issue persists, cause I'm not sure if I could reproduce it.
  • Tobias, with the new version of provided client lib the error gone, so you won it, congratulations! :)
    At least, my old network scenarion which I used with PUN 1.15 is working without noticeable errors.

    But an issue I've mentioned in the post above is not clarified yet (maybe I should start another thread on it?)
    demid wrote:
    Tobias, to be more specific, the way of level load triggering inside OnPhotonPlayerConnected() led to a new trouble: one client loads a level faster than another stops accepting messages from the opponent and it leads to an invalid RPC call to a nonexisting PhotonView. I suppose that the same error could occur in my previous network scenario but anyway this is realistic and I finally can not understand what is the best way to make both players start a game at the same time. Do you have a ready out-of-the-box scenario of synchronous level start for two (or more) players while they should initiate game start from the lobby scene?
    In theory the same trouble might happen in my old network scenario and the way of initial players synchronization should deal with this possibility.
  • Tobias
    Options
    Thanks for the feedback. Good news. :D

    Yes, let's please create another topic for the other question. So far I think:
    You stop the message queue in OnPhotonPlayerConnected for all players.
    One of those stops the queue but still gets a RPC called immediately, despite this?
    If I'm misunderstanding something, please clarify. We do not (yet) have a fitting sample.
  • Tobias, I've started a new thread for my problem with game synchronization: http://forum.exitgames.com/viewtopic.php?f=17&t=2071
  • 2Kin
    Options
    I will test your files with my PhotonViews set at "reliable" and make a feedback asap.
  • Tobias
    Options
    With the updated libs (from this topic), you don't have to change from reliable to unreliable. In fact, it's better when you don't, to test the files.
    I also put the new version live as new SDK (v3.0.1.13) but I didn't yet update PUN in the Asset Store.
  • 2Kin
    Options
    In the last try, it's Unreliable who makes my game showing this error.
    Wathever, I've made this test, and now it seems ok with your update. I always have the problem I sent you by email and that is followed by your bug tracker, but this one is ok now.
  • Just letting you know this latest lib has fixed the problem for me as well.

    thanks
  • Tobias
    Options
    Thanks for letting me know, everyone. Good this helped.