Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Photon exception on client after disconnect event #70

Closed
dwoodruffsf opened this issue May 10, 2021 · 2 comments
Closed

Photon exception on client after disconnect event #70

dwoodruffsf opened this issue May 10, 2021 · 2 comments
Labels
type:bug Bug Report

Comments

@dwoodruffsf
Copy link

Describe the bug
After getting disconnected from photon, the client sometimes develops an exception that fires every frame. This bug is a complement to bug Unity-Technologies/com.unity.netcode.gameobjects#823. It isn't wrong that the client gets disconnected (although the timeout of only a few seconds is pretty aggressive). But it seems that the PhotonRealtimeTransport is in a bad state after the shutdown, and generates exceptions.

To Reproduce

  1. Open the BossRoom demo in editor. Window->Photon Realtime->Highlight Server Settings.
  2. Put in your own personal appid from photonengine.com
  3. Start the game in a separate built client, select "Start", and then "Relay Host".
  4. Start the game in editor, select "Join", "Relay Host", and the room name.
  5. Once both host and client are in character select, pick character and enter the game.
  6. Walk around with the joiner client and pick a fight with an imp (I think having some active network traffic is helpful in getting the exception).
  7. Pull your network cable. Count to 5, then plug it back in.
  8. Observe that sometimes (around 50% of the time), after you are returned to main menu, you get a continuous stream of exceptions from the PhotonRealtimeTransport

Actual outcome
An exception gets thrown every frame after a client gets disconnected from the Photon Relay Server.

Expected outcome
No exceptions are generated.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. Windows 10]
  • Unity Version: [e.g. 2019.1]
  • MLAPI Version: [e.g. v6.0.1]
  • MLAPI Commit: [e.g. https://github.com/Unity-Technologies/com.unity.multiplayer.mlapi/commit/c102935df1d7e0928283b48948fe96e5d96dd961]

Additional context

callstack of the Exception. m_Client is null, which is no surprise, since NetworkManager has already been Shutdown by this point.

Int32 MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:get_CurrentMasterId ()+0x0 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350ae57\Runtime\PhotonRealtimeTransport.Matchmaking.cs:[15:34-15:115]	C#
Int32 MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:GetPhotonRealtimeId (UInt64)+0xc at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350ae57\Runtime\PhotonRealtimeTransport.cs:[472:17-472:40]	C#
Void MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:RaisePhotonEvent (UInt64, Boolean, ArraySegment`1, Byte)+0xf at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350ae57\Runtime\PhotonRealtimeTransport.cs:[245:13-245:87]	C#
Void MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:FlushAllSendQueues ()+0x58 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350ae57\Runtime\PhotonRealtimeTransport.cs:[231:17-231:113]	C#

Void MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:LateUpdate ()+0x2 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350a\Runtime\PhotonRealtimeTransport.cs:[114:13-114:34] C#

This is the callstack showing the network shutdown the client gets, triggered by a Disconnect event from the Photon relay server.

Void MLAPI.NetworkManager:Shutdown ()+0x1 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.unity.multiplayer.mlapi@3e3aef6aa0\Runtime\Core\NetworkManager.cs:[603:13-603:66]	C#
Void MLAPI.NetworkManager:StopClient ()+0x3d at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.unity.multiplayer.mlapi@3e3aef6aa0\Runtime\Core\NetworkManager.cs:[512:13-512:24]	C#
Void MLAPI.NetworkManager:HandleRawTransportPoll (NetworkEvent, UInt64, NetworkChannel, ArraySegment`1, Single)+0x182 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.unity.multiplayer.mlapi@3e3aef6aa0\Runtime\Core\NetworkManager.cs:[895:25-895:38]	C#
Void MLAPI.Transports.NetworkTransport:InvokeOnTransportEvent (NetworkEvent, UInt64, NetworkChannel, ArraySegment`1, Single)+0x14 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.unity.multiplayer.mlapi@3e3aef6aa0\Runtime\Transports\NetworkTransport.cs:[123:13-123:92]	C#

Void MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:InvokeTransportEvent (NetworkEvent, UInt64, NetworkChannel, ArraySegment`1)+0x41 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350a\Runtime\PhotonRealtimeTransport.cs:[424:21-424:113] C#
Void MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:OnPlayerLeftRoom (Player)+0x3c at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350a\Runtime\PhotonRealtimeTransport.Room.cs:[48:17-48:58] C#
Void Photon.Realtime.InRoomCallbacksContainer:OnPlayerLeftRoom (Player)+0x22 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350a\Runtime\Photon\PhotonRealtime\Code\LoadBalancingClient.cs:[4184:17-4184:54] C#
Void Photon.Realtime.LoadBalancingClient:OnEvent (EventData)+0x2d5 at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350a\Runtime\Photon\PhotonRealtime\Code\LoadBalancingClient.cs:[3197:21-3197:84] C#
Boolean ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback (StreamBuffer)+0x2e9 at :-1 C#
Boolean ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands ()+0x3b6 at :-1 C#
Boolean ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands ()+0x3a at :-1 C#
Void MLAPI.Transports.PhotonRealtime.PhotonRealtimeTransport:Update ()+0x1c at C:\dev\com.unity.multiplayer.samples.coop\Library\PackageCache\com.mlapi.contrib.transport.photon-realtime@3f0350a\Runtime\PhotonRealtimeTransport.cs:[105:24-105:86] C#

@Tobias-EG
Copy link
Contributor

Thanks for the report. Easy to repro. Fix is in a pr. Same core issue as #69 .

ThusSpokeNomad pushed a commit that referenced this issue Jun 2, 2021
* FIXED: NullreferenceException on import. The Window opens so early that the AppSettingsInstance can be null still.

* FIXED: Issue "Photon exception on client after disconnect event" (#70).

* ADDED: Limit for the number of datagrams sent in a single frame. Simple way to avoid overloading the local network.

* FIXED: Potential nullreference exception in DisconnectRemoteClient (should the local client get disconnected before this is called).

* ADDED: TransportEvent Disconnect for case when RaisePhotonEvent can't succeed (client is null or not in room).
@LukeStampfli
Copy link
Contributor

Fixed by #73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Bug Report
Projects
None yet
Development

No branches or pull requests

4 participants