AMacro / dv-multiplayer

A DerailValley mod adding multiplayer to the game.
Apache License 2.0
7 stars 3 forks source link

Host gets stuck with `WorldPosition() Exception` after client connects #49

Open matejdro opened 5 days ago

matejdro commented 5 days ago

We found that sometimes, when client attempts to connect to the host, host's simulation will freeze. Its CPU usage will skyrocket and most operations (such as connect/disconnect or saving the game) will not work anymore. Presumably, it gets stuck in an infinite loop. Following kept being printed into the logs repeatedly:

[16:10:52.312] [Warning] WorldPosition() Exception Nejc
[16:10:52.312] [Warning] 
[16:10:52.312] [Warning]   at (wrapper managed-to-native) UnityEngine.Component.get_transform(UnityEngine.Component)
  at Multiplayer.Networking.Data.ServerPlayer.get_WorldPosition () [0x00043] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
[16:10:52.313] [Warning] WorldPosition() Exception Nejc
[16:10:52.313] [Warning] 
[16:10:52.313] [Warning]   at (wrapper managed-to-native) UnityEngine.Component.get_transform(UnityEngine.Component)
  at Multiplayer.Networking.Data.ServerPlayer.get_WorldPosition () [0x00043] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
[16:10:52.315] [Error] Exception while processing OnTick: System.NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component.get_transform(UnityEngine.Component)
  at Multiplayer.Components.Networking.Player.NetworkedWorldMap.UpdatePlayers () [0x000aa] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at Multiplayer.Components.Networking.Player.NetworkedWorldMap.OnTick (System.UInt32 obj) [0x00015] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at (wrapper delegate-invoke) System.Action`1[System.UInt32].invoke_void_T(uint)
  at Multiplayer.Components.Networking.NetworkLifecycle+<PollEvents>d__45.MoveNext () [0x00067] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
[16:10:52.316] [Error] [Client] Exception while polling events: System.NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component.get_transform(UnityEngine.Component)
  at Multiplayer.Components.Networking.Player.NetworkedPlayer.UpdateCar (System.UInt16 netId) [0x0000e] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at Multiplayer.Networking.Listeners.ClientPlayerManager.UpdatePosition (System.Byte id, UnityEngine.Vector3 position, UnityEngine.Vector3 moveDir, System.Single rotation, System.Boolean isJumping, System.Boolean isOnCar, System.UInt16 carId) [0x00011] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at Multiplayer.Networking.Listeners.NetworkClient.OnClientboundPlayerPositionPacket (Multiplayer.Networking.Packets.Clientbound.ClientboundPlayerPositionPacket packet) [0x00035] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at LiteNetLib.Utils.NetPacketProcessor+<>c__DisplayClass28_0`1[T].<SubscribeReusable>b__0 (LiteNetLib.Utils.NetDataReader reader, System.Object userData) [0x00018] in <2af6a78ac53a4d3dbe588de2359878e4>:0 
  at LiteNetLib.Utils.NetPacketProcessor.ReadPacket (LiteNetLib.Utils.NetDataReader reader, System.Object userData) [0x00007] in <2af6a78ac53a4d3dbe588de2359878e4>:0 
  at LiteNetLib.Utils.NetPacketProcessor.ReadAllPackets (LiteNetLib.Utils.NetDataReader reader, System.Object userData) [0x00002] in <2af6a78ac53a4d3dbe588de2359878e4>:0 
  at Multiplayer.Networking.Listeners.NetworkManager.OnNetworkReceive (LiteNetLib.NetPeer peer, LiteNetLib.NetPacketReader reader, System.Byte channelNumber, LiteNetLib.DeliveryMethod deliveryMethod) [0x00007] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at LiteNetLib.NetManager.ProcessEvent (LiteNetLib.NetEvent evt) [0x000a5] in <2af6a78ac53a4d3dbe588de2359878e4>:0 
  at LiteNetLib.NetManager.PollEvents () [0x0008c] in <2af6a78ac53a4d3dbe588de2359878e4>:0 
  at Multiplayer.Networking.Listeners.NetworkManager.PollEvents () [0x00000] in <d2f67c64b0c144d8bc4c908418b1378d>:0 
  at Multiplayer.Components.Networking.NetworkLifecycle.TickManager (Multiplayer.Networking.Listeners.NetworkManager manager) [0x00021] in <d2f67c64b0c144d8bc4c908418b1378d>:0 

Full Host log from that session: ServerCrash.txt

Note that we experienced this with the Rolling Stock Ownership mod installed. If crashes when running other mods are out of scope, please feel free to close this issue.

AMacro commented 5 days ago

Hi @matejdro,

Other mods are currently out of scope - our primary aim is to get vanilla game play working in a multiplayer environment. Once we have achieved this, we will be looking to gain compatibility with as many mods as possible.

I will leave it open for when we get to this stage, as it might help us understand which mods cause issues and what the mod might be doing.