NullReferenceException on MasterClient transfer

Having some trouble figuring out what's happening here, perhaps someone can shed some light.

A GameObject is instantiated using InstantiateSceneObject(),
Player 2 joins,
Player 1, MasterClient, disconnects and ownership is transferred to Player 2,
this.photonView now returns null and I'm getting a NullReferenceException

While debugging I've found:
* The photonView component definitely exists on the GameObject in the Unity Editor on Player 2's machine
* The inspector shows Player 2 is the owner of that photonView
* Everything works great BEFORE the masterclient transfers ownership

RPCs are sent and received on the GameObject in question and I believe the client and all of the views are in the same group.

Any ideas?


Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited June 2017
    Hi @SuppleTeet,

    Thank you for choosing Photon!

    Please share the full NullReferenceException stacktrace.
    And which PUN do you use?
  • Hey JohnTube,

    I'm taking over for SuppleTeet.

    Context
    The error conditions are:
    1. The master client switches.
    2. A player (master or other) selects a button
    3. On the new master client, SyncManager SetButtonTakenBy turns up a null reference:

    Error
    NullReferenceException: Object reference not set to an instance of an object
    SyncManager.SetButtonTakenBy (Int32 buttonIndex, Int32 playerIndex) (at Assets/Scripts/Engine/SyncManager.cs:397)
    LobbyStartButton.OnTriggerEnter (UnityEngine.Collider other) (at Assets/Scripts/LobbyStartButton.cs:73)

    Photon Version
    Photon Unity Networking v1.82

    Images of the Call Stack and locals are here. Lmk if you have issues viewing or if there is something else you need.
    https://drive.google.com/drive/folders/0B0h2lz1HNrOqanpTUEhONTNSMDQ?usp=sharing

    THANKS!!
  • Hey there,

    Just wanted to follow up that we solved it. We'd been storing a reference to our Photon object (SyncManager) in our Game Manager (God), and when the master client switched, that reference broke. So in the function call in LobbyStartButton, syncManager was null.

    Why did the reference break? SyncManager is PhotonInstantiateSceneObject. All the instances of the game have a SyncManager, which the local Game Managers refer to. Why do those references break when the master client, and ownership of the syncManager, switches?

    Thanks,
    Atley