Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Unity Multiplayer Help understanding error in LocalClient.ProcessInternalMessages

Discussion in 'Connected Games' started by robochase, Sep 30, 2017.

  1. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    220
    I got this error a couple times last night, and I'm not too sure what to say about it -

    Looking over the loops in ProcessInternalMessages, it seems like this error should never happen. So why would it?

    Including the LocalClient.ProcessInternalMessages code -

    Code (CSharp):
    1. private void ProcessInternalMessages()
    2. {
    3.     if (m_InternalMsgs.Count == 0)
    4.     {
    5.         return;
    6.     }
    7.  
    8.     // new msgs will get put in m_InternalMsgs2
    9.     List<InternalMsg> tmp = m_InternalMsgs;
    10.     m_InternalMsgs = m_InternalMsgs2;
    11.  
    12.     // iterate through existing set
    13.     foreach (var msg in tmp)
    14.     {
    15.         if (s_InternalMessage.reader == null)
    16.         {
    17.             s_InternalMessage.reader = new NetworkReader(msg.buffer);
    18.         }
    19.         else
    20.         {
    21.             s_InternalMessage.reader.Replace(msg.buffer);
    22.         }
    23.         s_InternalMessage.reader.ReadInt16(); //size
    24.         s_InternalMessage.channelId = msg.channelId;
    25.         s_InternalMessage.conn = connection;
    26.         s_InternalMessage.msgType = s_InternalMessage.reader.ReadInt16();
    27.  
    28.         m_Connection.InvokeHandler(s_InternalMessage);
    29.         m_FreeMessages.Push(msg);
    30.         connection.lastMessageTime = Time.time;
    31.     }
    32.  
    33.     // put m_InternalMsgs back and clear it
    34.     m_InternalMsgs = tmp;
    35.     m_InternalMsgs.Clear();
    36.  
    37.     // add any newly generated msgs in m_InternalMsgs2 and clear it
    38.     foreach (var msg in m_InternalMsgs2)
    39.     {
    40.         m_InternalMsgs.Add(msg);
    41.     }
    42.     m_InternalMsgs2.Clear();
    43. }
    I'd guess one of those foreach loops is messing up..probably the first one. Looking at this a bit deeper, it seems like this function is only really called by UNetStaticUpdate so I'm not totally sure how this could be breaking.
     
  2. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    220
    bump. saw this happen again tonight. any ideas?
     
unityunity