Cannot serialize() when second client joins.

Hi,

My game runs perfectly when the master client creates and joins a room.

But when the second client joins, I get this error spammed about 20 times in my console:

[Code]
Exception: cannot serialize(): System.Collections.Generic.List`1[System.String]
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeObjectArray (ExitGames.Client.Photon.StreamBuffer dout, System.Object[] objects, Boolean setType)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeHashTable (ExitGames.Client.Photon.StreamBuffer dout, ExitGames.Client.Photon.Hashtable serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.Serialize (ExitGames.Client.Photon.StreamBuffer dout, System.Object serObject, Boolean setType)
ExitGames.Client.Photon.Protocol16.SerializeParameterTable (ExitGames.Client.Photon.StreamBuffer stream, System.Collections.Generic.Dictionary`2 parameters)
ExitGames.Client.Photon.Protocol16.SerializeOperationRequest (ExitGames.Client.Photon.StreamBuffer stream, Byte operationCode, System.Collections.Generic.Dictionary`2 parameters, Boolean setType)
ExitGames.Client.Photon.EnetPeer.SerializeOperationToMessage (Byte opCode, System.Collections.Generic.Dictionary`2 parameters, EgMessageType messageType, Boolean encrypt)
ExitGames.Client.Photon.EnetPeer.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypt, EgMessageType messageType)
ExitGames.Client.Photon.PeerBase.EnqueueOperation (System.Collections.Generic.Dictionary`2 parameters, Byte opCode, Boolean sendReliable, Byte channelId, Boolean encrypted)
ExitGames.Client.Photon.PhotonPeer.OpCustom (Byte customOpCode, System.Collections.Generic.Dictionary`2 customOpParameters, Boolean sendReliable, Byte channelId, Boolean encrypt)
LoadBalancingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/LoadbalancingPeer.cs:776)
NetworkingPeer.OpRaiseEvent (Byte eventCode, System.Object customEventContent, Boolean sendReliable, .RaiseEventOptions raiseEventOptions) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1036)
NetworkingPeer.RunViewUpdate () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:4140)
PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:164)
[/Code]

What does this mean, and how can I solve it?

I would normally expect this sort of error message if I'm registering an invalid type, but that doesn't seem to be the case.

Best Answers

  • Joehot200
    Joehot200
    edited July 2018 Answer ✓
    Just realized I was trying to serialize a List< string >..... Thanks for helping me find the problem. :)

Answers

  • Just to clarify, these errors occur on the host, not the joining client. The host has no errors until the other client joins.
  • Hi @Joehot200,

    the error message states that you are trying to serialize a List which is not possible with PUN by default. What you can do instead, is either to register a Custom Type which requires some effort or to cast the List to an Array which might be easier and is support by PUN by default. To do so, you can use the ToArray(); function on the List. Please note: if you have other unsupported objects in that List (e.g. GameObject) it won't work, too.
  • Hi @Joehot200,

    the error message states that you are trying to serialize a List which is not possible with PUN by default. What you can do instead, is either to register a Custom Type which requires some effort or to cast the List to an Array which might be easier and is support by PUN by default. To do so, you can use the ToArray(); function on the List. Please note: if you have other unsupported objects in that List (e.g. GameObject) it won't work, too.

    But what am I trying to serialize, and where? Why do no errors show up when the first client shows up, but then they all show up when the second client shows up? The error doesn't seem to indicate what or where I am trying to serialize, and there's a bunched of serialized stuff in my game.
  • But what am I trying to serialize, and where?


    The only thing I can say is that this is a OnPhotonSerializeView call. The stacktrace doesn't provide more information (at least on the first look).

    Why do no errors show up when the first client shows up, but then they all show up when the second client shows up?


    OnPhotonSerializeView is not called if there is only one client in the room. It gets only called if there are two or more players in the room.

    The error doesn't seem to indicate what or where I am trying to serialize, and there's a bunched of serialized stuff in my game.


    As said, you are looking for a OnPhotonSerializeView function where you try to serialize (stream.isWriting) a list.
  • Joehot200
    Joehot200
    edited July 2018


    As said, you are looking for a OnPhotonSerializeView function where you try to serialize (stream.isWriting) a list.
    Could I also be looking for a PunRPC?
  • I've checked all my scripts, and I cannot see a single thing that I would be serializing incorrectly. I also don't understand why the error is spammed tons of times. If there's one thing I missed, surely the error would only be shown once?
  • Joehot200
    Joehot200
    edited July 2018 Answer ✓
    Just realized I was trying to serialize a List< string >..... Thanks for helping me find the problem. :)