MissingReferenceException: The object of type 'PhotonView' has been destroyed but you are still tryi

Options
Hi,
We are using PUN+ 1.73. We have set autoCleanUpPlayerObjects to true. This exception happens very rarely when more than one player disconnects simultaneously. Because of this exception we see game objects of disconnected players in game.

Did this happen to anyone? What are the possible scenarios where it can happen. We are not destroying anything from our code.

MissingReferenceException: The object of type 'PhotonView' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
NetworkingPeer.DestroyPlayerObjects (Int32 playerId, Boolean localOnly) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2969)
NetworkingPeer.HandleEventLeave (Int32 actorID, ExitGames.Client.Photon.EventData evLeave) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1205)
NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2222)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:125)

Comments

  • avinash
    avinash
    edited August 2016
    Options
    We have fixed it by putting null check in NetworkingPeer class line 2967. After putting logs we noticed that view was null on many occasions. Just by putting null check now objects are cleared properly.
    if (view!=null && view.CreatorActorNr == playerId)
    {
        playersGameObjects.Add(view.gameObject);
    }
  • jeanfabre
    Options
    Hi,

    ok, This should be available in the next update. Thanks for reporting :)

    Bye,

    Jean
  • develax
    develax ✭✭
    edited August 2019
    Options
    @jeanfabre
    the same error in another place:

    MissingReferenceException: The object of type 'PhotonView' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    Photon.Pun.PhotonNetwork.LocalCleanupAnythingInstantiated (System.Boolean destroyInstantiatedGameObjects) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:259)
    Photon.Pun.PhotonNetwork.LeftRoomCleanup () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetworkPart.cs:235)
    Photon.Pun.PhotonNetwork+<>c.<.cctor>b__122_0 (Photon.Realtime.ClientState previousState, Photon.Realtime.ClientState state) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:990)
    Photon.Realtime.LoadBalancingClient.set_State (Photon.Realtime.ClientState value) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:355)
    Photon.Realtime.LoadBalancingClient.Disconnect () (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:928)
    Photon.Realtime.ConnectionHandler.OnDisable () (at Assets/Photon/PhotonRealtime/Code/ConnectionHandler.cs:91)
    Photon.Pun.PhotonHandler.OnDisable () (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:120)