NullRef in RPC() error handling when function name is wrong and there is no parameter (Pun 2.9)

Hello,

I haven't updated to the newest Pun but there's nothing about this bug in the 2.11 and 2.12 changelog (haven't seen the 2.10 changelog as it's not on the asset store).

If I call PhotonView.RPC() with a function name that has a typo, and the RPC call has zero custom arguments, then I get this nullref:

NullReferenceException: Object reference not set to an instance of an object
Photon.Pun.PhotonNetwork.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, Photon.Realtime.Player sender) (at Assets/Tools/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:506)

In case the code in PhotonNetworkPart.cs has changed since 2.9, here are the offending lines:
            // Error handling
            if (receivers != 1)
            {
                string argsString = string.Empty;
                for (int index = 0; index < argumentsTypes.Length; index++)
(more specifically the last one)

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @olistan,

    Are you saying this happens on 2.12 but not on 2.11?
    How can we reproduce? minimal steps required.
  • It happens on 2.9. I haven't tried 2.10, 2.11 or 2.12.

    To reproduce, just call GetComponent< PhotonView >().RPC("NonExistantFunction", RpcTarget.All).
  • The bug is still in PUN 2.13. NullRef in PhotonNetworkPart.cs line 508.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Why do you need to call a non existing RPC method?
    PUN RPCs expect the method with the same name to be there on the PhotonView.
    So maybe what you see is the normal behaviour when it's not there.

    What should be the expected behaviour according to you?
  • I do not need to call a non existing RPC method. There is a bug in our code that triggers this code in PUN which is supposed to display an error message telling us which is the wrong RPC name we tried to call, but this error logging code is bugged so we only get a nullref and no useful error message.
  • JohnTube
    JohnTube ✭✭✭✭✭
    OK, we will investigate.
    Thanks.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited September 2019
    Hi @olistan,

    Thanks again for your report and sorry for the late reply.

    In case you didn't fix it yourself already:
    The fix for the NullReferenceException will be there in the next PUN2 version.
  • Great news @JohnTube, thanks for keeping me updated!