Reliability Exceptions in the Fusion Protocol
In most cases, Fusion guarantees that reliable RPCs and changes to Networked Properties
are synchronized to other peers. Even when network packets are lost due to packet loss Fusion synchronizes the lost data again.
Networked Properties
For Networked Properties
Fusion applies Eventual Consistency to synchronize their data.
There are some edge cases in which eventual consistency is not guaranteed or might give an unintended result that are documented below.
Multiple Changes in Quick Succession
Changing a Networked Property
in quick succession can result in some changes not being detected due to how Eventual Consistency works.
Examples:
- Changing a Int Networked Property from
5
to6
to7
in quick succession might result in other peers only receiving a single change from5
to7
. - Changing a Bool Networked Property from
True
toFalse
toTrue
in quick succession might result in other peers receiving no change at all (fromTrue
toTrue
). For this case we recommend using an Int property and incrementing the value on each change and havingeven
numbers representFalse
anduneven
numbers representTrue
.
Shared Mode Prediction
Setting a Networked Property
to a value without having StateAuthority in Shared Mode leads to a Shared Mode Prediction
. This results in:
- The modification is only local and not synchronized to other peers.
- The prediction is not automatically reset after a certain period of time unlike in Host / Server Mode. It is possible to end up with a permanent desynchronization of Networked Property values between peers.
- When the StateAuthority next sets the value of the property, the predicted value will be overridden with the value from the StateAuthority when the state change is received.
In Fusion 2.1 and newer NetworkObject.ResetToLatestState()
can be called to reset all Shared Mode predicted Networked Properties of an object locally.
State Authority Changes
In Shared Mode if a client sets the value of a Networked Property while having StateAuthority usually that change is synchronized to other clients. However, if this is done at the same time as another client calls RequestStateAuthority
over the object it is possible that the changes are not synchronized leading to a Shared Mode Prediction
. This prediction is always temporary and the previous StateAuthority is given a correct object state once the Photon Server Plugin assigns the new StateAuthority for the object.
RPCs
Reliable RPCs are guaranteed to arrive except in some cases when:
- The NetworkObjectobject does not exist on the receiving peer. (It has already been despawned or not yet been spawned)
- StateAuthority / InputAuthority of the NetworkObject changes while the RPCs is being sent. (Specific cases explained below)
- The client completely disconnects while the RPC is being sent / received.
Static RPCs can be used to have RPCs arrive without having to worry about issues with NetworkObjects being present or having the correct StateAuthority.
RPCs Immediately After Spawning
RPCs sent in Spawned()
or shortly after the object is spawned are not guaranteed to arrive. A race condition is possible where the RPC arrives on the receiving peer before the object is spawned causing the RPC to be discarded.
RPCs when Despawning
RPCs sent at the same time as an object is being despawned or in a time frame before the despawn are not guaranteed to be executed. The RPCs can arrive before or after the object is despawned and RPCs arriving after the object is despawned are dropped.
To guarantee an RPC is executed before a despawn it is necessary to send a confirmation RPC back from the target indicating that the RPC has been received before the object is despawned.
Shared Mode RPCs
RPCs with RpcSource.StateAuthority
get discarded when the StateAuthority of the NetworkObject changes on the Photon Cloud Plugin before the RPC arrives. RpcSources.All
to guarantee the RPC is still delivered in this case but a manual authority check is needed to replace the StateAuthority check.
RPCs with RpcTarget.StateAuthority
get discarded when the StateAuthority of the NetworkObject changes on the Photon Cloud Plugin before the RPC arrives. To guarantee an RPC is delivered in this case a Targeted RPC with the target set to the StateAuthority can be used.
Host / Server Mode RPCs
RPCs sent from the InputAuthority (client) to the StateAuthority (server) have their InputAuthority checked on the server when received. If a NetworkObject has its InputAuthority changed on the server and an RPC from the previous InputAuthority with RpcSources.InputAuthority
is received, the RPC is discarded.
RpcSources.All
can be used to always have the RPC invoked on the server, but a manual authority check is needed to replace the InputAuthority check.