Application frozen in Photon.SupportClass.()

Options
Hi team,

I am not sure whether this issue was reported.

I am using PUN v1.88 (20. December 2017) for Unity. My game frozen randomly several times and when I tried to debug, I found the thread was sleeping in SupportClass.() and didn't exit. So I shall quit Unity and restart the game. In the editor, the call stack was like
ExitGames.Client.Photon.SupportClass. ()
System.Threading.Thread.Sleep(millisecondsTimeout=100)

Thanks,
Wenbo

Answers

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited March 2018
    Options
    Hi @wenbo_MA,

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

    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).
  • wenbo_MA
    Options
    Thank you for your reply @JohnTube .

    I don't think my question is related to the one you referred.
    The version of Unity is 2017.2.0.f3. I wrote the PUN version there already. It is v1.88.

    The first answer you said "call PhotonNetwork.Disconnect() in one OnApplicationQuit()". Whether you concern the last instance of my application still affect the new instance because it is trying to connect or keeping connect to PUN server, though it was closed already?

    For the second answer you said, "enabling RunInBackground for Editor". I will try this. Since this issue doesn't appear frequently, I can't ensure whether this is the correctly solution. And you also mentioned "call PhotonNetwork.Disconnect() for Editor only (#if UNITY_EDITOR) in one of these cases OnApplicationFocus(false) or OnApplicationPause(true)." I am afraid this isn't the best practice for users to debug because once a breakpoint was triggered while several clients including the instance in the editor itself are connecting to your server, the connection of the instance in the editor will lose due to PhotonNetwork.Disconnect is called in OnApplicationPause. Is my assumption correct?

    Thank you again,
    Wenbo
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @wenbo_MA,

    First, you should know that debugging using breakpoints is tricky as it may result in timeout disconnects for the client. Read more about this here.

    I wrote the PUN version there already.
    Sorry about that! I wrote the same message content for the two discussions.

    Whether you concern the last instance of my application still affect the new instance because it is trying to connect or keeping connect to PUN server, though it was closed already?
    I'm assuming the issue is due to a background thread not being disposed of properly when you stop playing in Unity Editor so it becomes frozen.

    Since this issue doesn't appear frequently
    I thought this happens everytime. Can you find out what's different in these cases?

    Is my assumption correct?
    It could be. You can skip my suggestion for disconnecting when the editor is paused or loses focus.
  • Tobias
    Options
    We tried our best to have PUN disconnect properly, when an app closes or the editor exits play-mode. This is necessary, as Unity doesn't seem to end Threads in those cases, even though they are flagged as "Background Thread" (which should stop automatically, when the app is quit).

    Did you modify PUN somehow? Which platform are you working on and can you figure out any ways to reproduce this? How often does it happen?