Search Unity

Bug Crash when leaving a vivox channel in OnDisable while exiting play mode

Discussion in 'Vivox (Voice & Text Chat)' started by luis_unity981, Apr 3, 2023.

  1. luis_unity981

    luis_unity981

    Joined:
    Oct 11, 2022
    Posts:
    12
    I have a unity MonoBehaviour named ChatParticipant which joins a vivox channel in OnEnable and leaves in OnDisable. Whenever unity closes, it automatically disables and destroys all objects in the scene. When I try to leave the current channel in my OnDisable call while unity is exiting, it causes unity to completely crash.

    Most of the times that this happened, unity didn't even generate a crash report or give me access to the editor log. It just completely closed. However, I was somehow able to get a stack trace on only one of the crashes:

    at <unknown> <0xffffffff>
    at VivoxCoreInstancePINVOKE:vx_req_sessiongroup_remove_session_t_session_handle_set <0x0011b>
    at vx_req_sessiongroup_remove_session_t:set_session_handle <0x000ca>
    at VivoxUnity.Private.ChannelSession:Disconnect <0x003b2>
    at MegaParticle.PokerVRLD.Networking.ChatParticipant:LeaveChannel <0x0015f>
    at MegaParticle.PokerVRLD.Networking.ChatParticipant:OnDisable <0x000c2>
    at System.Object:runtime_invoke_void__this__ <0x00187>

    I am using the latest released version: 15.1.200000-pre.1

    i also already tried moving the logic to OnApplicationQuit and unity still crashes without providing any sort of error report or editor log
     
    Last edited: Apr 4, 2023
    AirUnity01 and Celine_ttr like this.
  2. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
    Try unitializing the vivox client instead. This will clean up Vivox resources and automatically disconnect players from channels and the Vivox network so you dont get charged for them anymore

    // Example
    Code (CSharp):
    1. public static VivoxUnity.Client Client = new Client();
    2.  
    3.     private void OnApplicationQuit()
    4.     {
    5.         Client.Uninitialize();
    6.     }
     
  3. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    222
    I have this from the Sample project and my Unity crashes almost everytime I exit playmode now...very annoying :(


    Code (CSharp):
    1.  private void OnApplicationQuit()
    2.         {
    3.             // Needed to add this to prevent some unsuccessful uninit, we can revisit to do better -carlo
    4.             Client.Cleanup();
    5.             if (_client != null)
    6.             {
    7.                 VivoxLog("Uninitializing client.");
    8.                 _client.Uninitialize();
    9.             }
    10.         }
     
  4. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
  5. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    222
    Thanks, I'll give your project a look at some time. However, my problem isn't that I cannot get Vivox to work - it works fine in my game no problem.
    My problem is that Unity crash when I exit play-mode while connected to Vivox.
     
  6. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
    @Laumania Oh Ok! Are you getting the same error as @luis_unity981? Also what version of Unity and Vivox are you using?
     
  7. zlaw777

    zlaw777

    Joined:
    Mar 9, 2015
    Posts:
    7
    Also experiencing this issue randomly multiple times per day. It tends to happen when exiting play mode

    Received signal SIGSEGV
    Obtained 30 stack frames
    0x000001ddebaefd4c (Mono JIT Code) (wrapper managed-to-native) VivoxCoreInstancePINVOKE:vx_req_sessiongroup_remove_session_t_session_handle_set (System.Runtime.InteropServices.HandleRef,string)
    0x000001ddebaefbdb (Mono JIT Code) [vx_req_sessiongroup_remove_session_t.cs:63] vx_req_sessiongroup_remove_session_t:set_session_handle (string)
    0x000001ddebaff32b (Mono JIT Code) [ChannelSession.cs:422] VivoxUnity.Private.ChannelSession:Disconnect (System.AsyncCallback)
     
  8. Laumania

    Laumania

    Joined:
    Jun 27, 2012
    Posts:
    222
    Yep, I still have the same. It seems to happen if you exit play mode before signingout/closing Vivox. It should happen in OnDestroy as I remember, but somehow it seems to not complete before it shutsdown and then crash entire Unity.

    What I have done, it simple to not login if I'm running in the Editor.
     
  9. 4ipideil

    4ipideil

    Joined:
    Jan 22, 2015
    Posts:
    13
    what works for me:


    Code (CSharp):
    1.  protected override void OnApplicationQuit()
    2. {
    3.      base.OnApplicationQuit();
    4.      if (_client != null)
    5.      {
    6.          VivoxLog("Uninitializing client.");
    7.          /*DisconnectAllChannels(true);
    8.          if (LoginSession != null)
    9.          {
    10.              LoginSession.Logout();
    11.              LoginSession.PropertyChanged -= OnLoginSessionPropertyChanged;
    12.          }*/
    13.          LoginSession = null;
    14.          new Thread(() =>
    15.          {
    16.              _client.Uninitialize();
    17.              _client = null;
    18.          }).Start();
    19.      }
    20. }
    its not solving the issues but at least instead of blocking the main unity thread it will block random noname thread
     
    Laumania likes this.