Room CustomProperties not ready in OnJoinedRoom, PUN2 2.10 > 2.17 inconsistency

Options
Hello,

we have noticed a difference in the Room CustomProperties synchronization between PUN2 2.10 and 2.17. With the latest version, users of our Asset Store asset run into an exception preventing successful initialization, thus not being able to play the game scene at all (very critical).

Below you will find screenshots of what is happening when running the exact same code on both PUN2 versions.
- we are calling PhotonNetwork.CurrentRoom.SetCustomProperties within OnCreatedRoom, to let the master set some default values for that room.
- the master (and other clients) are then accessing the room CustomProperties within OnJoinedRoom.

The first number in the Debug.Log is Time.realtimeSinceStartup.

PUN2 2.10
hexoreh6.png

PUN2 2.17
wadx4u2d.png

On PUN2 2.10, the CustomProperties immediately represent the desired count = 4 after the SetCustomProperties call, and before OnJoinedRoom happens.

On PUN2 2.17, the SetCustomProperties call needs ~230 milliseconds to actually update the CustomProperties, which is after the OnJoinedRoom callback happens. Therefore, accessing it from within OnJoinedRoom fails with NullReference exceptions for the master itself.

To repeat, this is the exact same game code - just updated PUN2 version. I could not find any related information about this, or a related change, in the change log for the PUN2 asset. Could you please provide more details about this change or a solution?

Thank you very much!
Florian

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited April 2020
    Options
    Hi @ReboundGames,

    Thank you for choosing Photon and for your report!

    The new behaviour is the correct one since rooms were being created by default with roomOptions.BroadcastPropsChangeToAll set to true.
    So if you want to have the old behaviour (set properties locally before sending the request to the server to synchronize them) set roomOptions.BroadcastPropsChangeToAll to false.

    The reason behind this:
    properties can easily go out of synchronization if we set them locally and then send the request to set them on the server and for other actors in the room, which might fail.
    so now the sender (actor that sets the properties) will wait for the server event PropertiesChanged to apply/set changes locally.
    of course this can be disabled as shown above.

    Thank you for your understanding!
  • ReboundGames
    Options
    Thank you for your answer, @JohnTube!

    I understand the reasoning behind this and actually it makes sense to have it on by default. For testing, I set BroadcastPropsChangeToAll to false as suggested.

    The resulting behavior is that running PUN2 2.10, both clients (master and client) have the updated properties available in OnJoinedRoom as before. While because of this no NullReference exceptions happen anymore, the OnRoomPropertiesUpdate callback is not invoked on the master client at all, which means that it does not react to the updated properties and still displays old data. The other clients react to OnRoomPropertiesUpdate as expected.

    In PUN2 2.17, with BroadcastPropsChangeToAll set to false, the OnRoomPropertiesUpdate callback is invoked on all clients, including the master client. This is indeed the behavior I am looking for, although only working that way with the latest PUN2 version.

    Thank you again for the explanation!
  • Tobias
    Options
    - we are calling PhotonNetwork.CurrentRoom.SetCustomProperties within OnCreatedRoom, to let the master set some default values for that room.

    Could you maybe set the props in CreateRoom instead? Then there is no gap for anyone joining.
  • ReboundGames
    Options
    You're right. I only looked at PhotonNetwork.CurrentRoom (which needs a room to exist) to set the properties, and completely forgot about PhotonNetwork.CreateRoom which allows passing in RoomOptions with properties during creation. It would need a bit of restructure in my code, but that totally works too.

    Thanks to both of you!