Confused by Serialization Behaviour

I was unable to find any record of similar serialization issues to the ones I'm having, due to not many instances of people attempting to layer containers in RPCs. I have a turn based game, and when the player readies up for the turn they send all of their actions for the current turn to the server to be processed. Original for this I was using just a large array of EntityActions (a custom class I created and provided serialization functions for), which was working without issue. However, I found that this resulted in the server receiving a spaghetti mess of actions without much organization. So I chose to upgrade to sending a dictionary which sorted separate action lists into separate arrays (Dictionary<int, EntityAction[]>). While this is a relatively complex structure to send over the network, the Serialization page said that "Dictionary<K,Object>" is serializable, and since I had already proven EntityAction[] to be serializable, I figured it would work. The resulting behaviour however is very odd. Attempting to send an RPC with a Dictionary<int, EntityAction[]> argument causes the sender to immediately be disconnected from the game (with no warning on either end aside from the disconnection warning to the client). Indeed, further testing confirmed that any Dictionary argument would result in this behaviour. Strangely enough, Dictionary<int, EntityAction> would result in warnings that INT is not serializable as a dictionary key, while Dictionary<int, int> would work exactly as intended.

I'm rather lost here, as I'm unsure if I have misinterpreted what Photon is capable of naturally serializing, as well as why this particularly behaviour is occurring as opposed to standard "unserializable" errors. Here is my serialization code for EntityActions (however as I said, this worked perfectly fine for sending single EntityActions or arrays of EntityActions): https://pastebin.com/PXRxRb9A

Serverside definition of the RPC call is
[PunRPC]
public void receiveActions(Dictionary<int, EntityAction[]> actions, int buffer, PhotonMessageInfo info)
Clientside call is
master.photonView.RPC("receiveActions", PhotonTargets.MasterClient, myActions, 6);

myActions is a Dictionary<int, EntityAction[]> as expected- contents are arbitary as the exact same results occur if I provide a blank dictionary of the correct typing as well.

If anyone knowledgeable of Photon's serialization can explain why this is occuring it would be greatly appreciated.

Comments

  • Hi @Ignoritus,

    Attempting to send an RPC with a Dictionary<int, EntityAction[]> argument causes the sender to immediately be disconnected from the game (with no warning on either end aside from the disconnection warning to the client).


    This can happen if you try to send too much data at once to the server. You can reproduce this for example by trying to send an array of type Quaternion containing 30.000 elements. This results in the same behaviour as described above while I have been testing this. So please check if you possibly send too much data.

    If this doesn't solve the problem please feel free to update us about the problem.