Application and even Unity Editor freeze upon exit after being connected to the network.

So, I do a build and have the application and the unity debugger both load up, get in a room together, then load a scene and each photonnetwork.instantiates a prefab. After this, trying to close the client in any way freezes it and it has to be killed with the task manager. The unity debugger stops debugging and seems fine until the next time you go to hit play it just freezes and has to be killed with the task manager. I've tried all sorts of code on an exit button to exit the network smoothly and the problem persists. I added PhotonNetwork.autocleanupwhatever = true and that seemed to maybe help the client quit nicely but the unity debugger still hangs next time you hit play.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Zerocyde,

    Thank you for choosing Photon!
    is this related to the other question here or is it just a coincidence?

    PhotonNetwork.autocleanupwhatever = true
    This should not have anything to do with this.


    What Unity version is this?
    What PUN version is this?

    Do you enable "Run In Background"?
    Did you change PhotonNetwork.BackgroundTimeout value?

    Try the following and report back:

    Please call PhotonNetwork.Disconnect() once in a MonoBehaviour in one OnApplicationQuit() or OnDestory().
    If you debug using breakpoints, try enabling RunInBackground for Editor only or call PhotonNetwork.Disconnect() for Editor only (#if UNITY_EDITOR) in one of these cases OnApplicationFocus(false) or OnApplicationPause(true).
  • Zerocyde
    Zerocyde
    edited March 2018
    Thanks for taking the time to reply. To answer your questions I'm currently using Unity 2017.3.1 and PUN v1.88. I do use PhotonNetwork.Disconnect(), and it does disconnect (you can see the instantiated gameobjects disappear on the other client's screen) but it just hangs there and you have to kill it with the task manager. The only thing it shows in the log is this...

    Can't execute Disconnect() while not connected. Nothing changed. State: PeerCreated
    (Filename: C:\buildslave\unity\build\artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)


    And to reitterate, there is no freezing when quitting the application if it has not yet done the...

    if (PhotonNetwork.isMasterClient) PhotonNetwork.LoadLevel(_mpSceneIndex);

    and loaded the scene for the two players.
  • You start the editor play session with the debugger attached? Or how do you reproduce this?
    Is this happening with our demos as well? E.g. the "Boxes Demo"?
  • Zerocyde
    Zerocyde
    edited March 2018
    Tobias said:

    You start the editor play session with the debugger attached? Or how do you reproduce this?
    Is this happening with our demos as well? E.g. the "Boxes Demo"?

    Doesn't matter how it starts. If I run 2 built clients they will both hang upon trying to exit the program having to be killed with the task manager. If it is one built client and the unity editor, the built client will hang and the unity editor will stop properly when I hit stop, and will continue to function normally until the next time I hit play in which it will hang and have to be killed with the task manager.

    This is happening exactly the same way for everyone on the team. I'll try messing with boxes demo next and report back.
  • Hmm. Ok, I didn't notice this yet but most of our demos don't load a scene.
    Did you try another Unity version (by chance)?
    The log you posted above: It's just a sign that Disconnect() got called more than once. It's not strickly needed to tell you, as the result should always be that we disconnect. It sounds like there's a race condition and some lock waits indefinitely.
    I will investigate.
  • Hmm. Ok, I didn't notice this yet but most of our demos don't load a scene.
    Did you try another Unity version (by chance)?
    The log you posted above: It's just a sign that Disconnect() got called more than once. It's not strickly needed to tell you, as the result should always be that we disconnect. It sounds like there's a race condition and some lock waits indefinitely.
    We will investigate.

    (Sorry, this reply somehow wasn't posted when I wrote it)
  • Could you repro this with the Boxes Demo?