Fusion needs input validation
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Fusion needs input validation
Supagoat
2022-07-17 22:31:07
I want to put networking into the game I'm making and I figured I'd give Fusion a try. What I've found is that it's not ready for prime time because I'm getting null reference exceptions from the Fusion codebase and I should never get a NRE from closed source code. A lot more input validation needs to be put into the engine with useful error messages because these NREs are just useless to me and I have no way to figure out what's going wrong.
The first problem I encountered I pretty quickly figured out on my own, which was that due to script order my NetworkRunner wasn't getting initialized before something else tried to spawn a NetworkObject, but the exception I got was a rather useless NRE:
NullReferenceException: Object reference not set to an instance of an object
Fusion.NetworkRunner.Spawn (Fusion.NetworkObject prefab, System.Nullable1[T] position, System.Nullable
1[T] rotation, System.Nullable1[T] inputAuthority, Fusion.NetworkRunner+OnBeforeSpawned onBeforeSpawned, System.Nullable
1[T] predictionKey, System.Boolean syncPhysics) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.cs:1687)
Fusion.NetworkRunner.Spawn (UnityEngine.GameObject prefab, System.Nullable1[T] position, System.Nullable
1[T] rotation, System.Nullable1[T] inputAuthority, Fusion.NetworkRunner+OnBeforeSpawned onBeforeSpawned, System.Nullable
1[T] predictionKey, System.Boolean syncPhysics) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.cs:1642)
And now I'm facing this one:
NullReferenceException: Object reference not set to an instance of an object
Fusion.NetworkRigidbody2D.SetIsKinematic (System.Boolean value) (at Fusion/Fusion.Runtime/Components/TransformBehaviours/NetworkRigidbody2D.Logic.cs:16)
Fusion.NetworkRigidbodyBase.Fusion.IStateAuthorityChanged.StateAuthorityChanged () (at Fusion/Fusion.Runtime/Components/TransformBehaviours/NetworkRigidbodyBase.Logic.cs:136)
Fusion.NetworkRunner.Fusion.Simulation.ICallbacks.ObjectStateAuthorityChanged (Fusion.NetworkId id) (at Fusion/Fusion.Runtime/Runner/NetworkRunner.SimulationCallbacks.cs:61)
UnityEngine.Debug:LogException(Exception)
If Fusion is this hard to debug for the simple stuff then there's no way I trust it for anything more complicated: Read "My game"
Comments
Thanks for the feedback. We agree that more checks and better exceptions / logs are needed, no question.
A colleague will try to help with the second issue in a bit.
Hi @Supagoat ,
Can you give us more information?
Which Fusion SDK build are you using?
In which context do these errors happen?
Do you have some reproduction steps to show this happening?
The second error happens if you are using NetworkRigidbody2D
from a Game Object that does not contain a Rigidbody2D
component on it. Is that the case?
--
Ramon Melo
Photon Fusion Team
Back to top