Photon Realtime SDK MissingReferenceException
I can reliably reproduce this exception in any project using the Photon Realtime SDK.
- Connect to name server
- Ping regions
- Connect to best region
- Call LoadBalancingClient.Disconnect
- Re-connect to name server
- Ping regions = MissingReferenceException
Photon Realtime Version 4.1.6.22 (21. December 2022 - rev6637)
Stack Trace:
MissingReferenceException: The object of type 'MonoBehaviourEmpty' 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. Photon.Realtime.MonoBehaviourEmpty.SelfDestroy () (at Assets/Photon/PhotonRealtime/Code/RegionHandler.cs:779) Photon.Realtime.RegionHandler.PingMinimumOfRegions (System.Action`1[T] onCompleteCallback, System.String previousSummary) (at Assets/Photon/PhotonRealtime/Code/RegionHandler.cs:243) ProjectName.MatchmakingPhotonRealtime.Photon.Realtime.IConnectionCallbacks.OnRegionListReceived (Photon.Realtime.RegionHandler regionHandler) (at Assets/com.ProjectName.matchmaking.photonrealtime/Runtime/MatchmakingPhotonRealtime.cs:93) Photon.Realtime.ConnectionCallbacksContainer.OnRegionListReceived (Photon.Realtime.RegionHandler regionHandler) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:4133) Photon.Realtime.LoadBalancingClient.OnOperationResponse (ExitGames.Client.Photon.OperationResponse operationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:2820) ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (ExitGames.Client.Photon.StreamBuffer stream) (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PeerBase.cs:872) ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/EnetPeer.cs:577) ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands () (at D:/Dev/Work/photon-dotnet-sdk/PhotonDotNet/PhotonPeer.cs:1771) ProjectName.MatchmakingPhotonRealtime.ProjectName.IMatchmaking.ReadIncomingMessages () (at Assets/com.ProjectName.matchmaking.photonrealtime/Runtime/MatchmakingPhotonRealtime.cs:62) ProjectName.PlayerLoop.OnPreUpdate () (at Assets/com.ProjectName.playerloop/Runtime/PlayerLoop.cs:93)
Code that causes the exception:
Comments
-
Oh. That makes sense.
Sorry for the hassle. I assume you fixed this temporarily on your end.
We'll update the Realtime SDK with a fix.
Thanks for the report.
0 -
Awesome. Thank you for the quick response!
0 -
If you could provide a repro case (minimal source / project), that would be welcome. At the moment, I don't reproduce this yet. Could be minimally newer code here.
Mail to: [email protected]
0 -
Minimal repro project sent to that email.
Steps to repro in repro project:
- enter app id in matchmakingphotonrealtime.cs
- Play
- App will auto join random room
- once in-room press 'f4'
- app will disconnect
- app will auto reconnect and try to ping regions
- error on ping regions
0 -
Thanks. Taking a look asap.
0 -
The fix / workaround is to use
if (this.emptyMonoBehavior != null) { this.emptyMonoBehavior.SelfDestroy(); }
instead of
this.emptyMonoBehavior?.SelfDestroy()
in PingMinimumOfRegions().The cause for this is Unity's weird-ish Null behavior for GameObjects and Monobehaviours. The equality comparison is overwritten to work with it but the Null-conditional operator doesn't do what you'd expect in this case.
Sorry for the hassle. We'll include a fix in the version following v4.1.6.22.
0 -
Perfect, thanks!
0