PhotonNetwork.Disconnect broken

Options
Hey,

I just started a new project using the most recent Photon version (Version: 1.61.1 (Sep 17, 2015)) and I'm experiecing a very strange behaviour regarding PhotonNetwork.Disconnect.

This is the code that connects my player. The connection, control, everything works fine:
void Start () {
PhotonNetwork.ConnectUsingSettings ("0.0.1");
}

void OnJoinedLobby()
{
PhotonNetwork.autoCleanUpPlayerObjects = true;

PhotonNetwork.JoinOrCreateRoom ("Default", null, TypedLobby.Default);
}

void OnJoinedRoom()
{
Debug.Log ("Ready.");

currentPlayer = PhotonNetwork.Instantiate ("Player", Vector3.zero, Quaternion.identity, 0).GetComponent();
}


I got another class UserInput that handles the input. This is what Update() looks like:
if (Input.GetKeyDown(KeyCode.Escape))
{
Debug.Log ("Disconnecting");

//if (playerController != null)
// PhotonNetwork.Destroy(playerController.gameObject.GetPhotonView());

PhotonNetwork.Disconnect();

//Application.Quit();
}


I did a build for PC and I started one project in the Unity Editor and two projects using the build .exe file. Everything works fine. Now I press Escape on one of the clients. The game freezes for this client and it does not receive further updates but the 3 players are still visible. The masterclient and the other client still see the third player and the masterclient even did take over the control and does control two players now.

What I would expect: The client gets destroyed and is gone as autoCleanUp should take care of it. It does work if I call Destroy manually but I thought Disconnect would handle that just fine?

Would love to hear something back on how to fix this issue.

Comments

  • avinash
    Options
    Hey,

    i too had an issue after updating to latest version (1.61.1). The issue is basically with Photon room's autoCleanUp. Its by default set to false.

    PhotonNetwork.autoCleanUpPlayerObjects = true;

    Above line should set this property to true but it doesn't because of v being only getter and its initialised before PhotonNetwork could have been set.

    Solution:
    Go to line no. 187 in Room.cs and comment out
    // this.autoCleanUpField = false; // defaults to false, unless set to true when room gets created.
    Add below line instead
    this.autoCleanUpField = true; // modified it to be true by default. Since this property doesn't have setter

    Make sure that this will always clean up all objects having PhotonViews attached once you leave the room.
  • -c.
    -c.
    edited September 2015
    Options
    same problem here.

    after the last update, autoCleanUp didn't work anymore.
    tried this PhotonNetwork.autoCleanUpPlayerObjects = true; but it didn't help either.

    in the end i created a setter for the autoCleanUp property in Room.cs, but the above solution works as well.
  • Same here
  • -c.
    -c.
    edited September 2015
    Options
    howdy, photon engine team
    is this issue going to be fixed soon or do we have to tweak the code that came with the asset?
  • vadim
    Options
    I'm afraid that we should wait for 2 weeks while Tobias is out of office.
    Sorry for inconvenience.
  • VR49
    Options
    Yea please fix this, it took me a while to figure out that the auto cleanup on disconnect totally fails to go through in v1.61.
  • Tobias
    Options
    Sorry about this issue. This issue is my bad.
    I refactored PUN to be more alike with our general LoadBalancing API and PUN currently doesn't set the room-property for for this setting.

    The fix should be to set the room property in the LoadBalancingPeer.RoomOptionsToOpParameters method. Find it and replace:

    op[ParameterCode.CleanupCacheOnLeave] = roomOptions.cleanupCacheOnLeave;

    with

    if (roomOptions.cleanupCacheOnLeave) { op[ParameterCode.CleanupCacheOnLeave] = true; // this is actually setting the room's config gameProperties[GamePropertyKey.CleanupCacheOnLeave] = true; // this is only informational for the clients which join }

    That should do the trick (but I didn't test this yet).
    PUN v1.62 will have a fix built in.
    Sorry again.
  • Tobias
    Options
    I just submitted PUN v1.62 to the Asset Store. It has a fix for this.
    Let me know, if anything is still odd.