Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.1k
stars
430
forks
source link
NullReferenceException during client Shutdown #2879
I use heavily custom messages and time to time client shutdown crashes. Don't have reproduce steps but concept is pretty simple:
// At Unity.Netcode.NetworkManager.ShutdownInternal()
...
CustomMessagingManager = null; // <= !!!
RpcTarget?.Dispose();
RpcTarget = null;
BehaviourUpdater?.Shutdown();
BehaviourUpdater = null;
// Shutdown connection manager last which shuts down transport
ConnectionManager.Shutdown(); // <= !!!
...
Problems is that ConnectionManager.Shutdown() does execute received messages and deep in stack there is UnnamedMessage.Handle which access NetworkManager.CustomMessagingManager => bhoom.
On surface level it seems that NetworkManager.CustomMessagingManager should be nullified after ConnectionManager.Shutdown();. I tried that and so far things seems to work well but my knowledge from library internals are limited.
Description
I use heavily custom messages and time to time client shutdown crashes. Don't have reproduce steps but concept is pretty simple:
Problems is that
ConnectionManager.Shutdown()
does execute received messages and deep in stack there isUnnamedMessage.Handle
which accessNetworkManager.CustomMessagingManager
=> bhoom.On surface level it seems that
NetworkManager.CustomMessagingManager
should be nullified afterConnectionManager.Shutdown();
. I tried that and so far things seems to work well but my knowledge from library internals are limited.Environment
Additional Context
Complete stacktrace: