UCL-VR / ubiq

Other
98 stars 34 forks source link

MissingReferenceException when leaving and rejoining a room using the Social Network Scene prefab #24

Closed TheBv closed 1 year ago

TheBv commented 1 year ago

When using the Social Network Scene prefab joining an existing room, leaving it and rejoining it will result in the following error:

MissingReferenceException: The object of type 'MeshRenderer' 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.
Ubiq.Samples.NetworkedMainMenuIndicator.SetVisibility (System.Boolean visible) (at Assets/ubiq/Unity/Assets/Samples/_Common/UI/Scripts/NetworkedMainMenuIndicator.cs:83)
Ubiq.Samples.NetworkedMainMenuIndicator.OnRecv () (at Assets/ubiq/Unity/Assets/Samples/_Common/UI/Scripts/NetworkedMainMenuIndicator.cs:134)
Ubiq.Samples.NetworkedMainMenuIndicator.ProcessMessage (Ubiq.Messaging.ReferenceCountedSceneGraphMessage message) (at Assets/ubiq/Unity/Assets/Samples/_Common/UI/Scripts/NetworkedMainMenuIndicator.cs:123)
Ubiq.Messaging.NetworkScene.ReceiveConnectionMessages () (at Assets/ubiq/Unity/Assets/Runtime/Messaging/NetworkScene.cs:270)
Ubiq.Messaging.NetworkScene.Update () (at Assets/ubiq/Unity/Assets/Runtime/Messaging/NetworkScene.cs:246)

Exact setup to reproduce: Client 1: Creates room Client 2: Joins room Client 2: Uses the "Leave" button to leave the room Client 2: Joins the same room again

Adding a null check to that part of the code fixes this but a similar issue arises at line #135/136

This was tested on the ubiq version from the 11th of November

bnco-dev commented 1 year ago

Thanks @TheBv. Think this should solve it, could you give that commit a try and close the issue if it fixes it for you?

TheBv commented 1 year ago

That seems to have fixed it! Thanks :)