Skip to content

Clients are receiving data from objects not visible to them. #915

@Sphisis

Description

@Sphisis

Hi!
I have a setup where I have clients and a headless server. Each client owns one object on the server and they are not destroyed on disconnect. Object ownerships are reclaimed by the clients on reconnection. In addition each client observes other players' objects only based on the distance from his own object. Player objects too far are invisible and unaware clients should not receive any traffic concerning them.

Describe the bug
If object is set invisible to a client A, but visible for client B, client A still receives message sync messages when server changes the object state via NetworkVariable:

[MLAPI] NETWORK_VARIABLE_DELTA message received for a non-existent object with networkObjectId: 2. This delta will be buffered and might be recovered.

When client A owned object turns invisible, it causes client B report an error:

Trying to destroy object 2 but it doesn't seem to exist anymore!

Finally if hidden object is destroyed, unaware clients report:

  • correction (when client a disconnects and transfers ownership to server, client b gets this report if object was not visible to it)

KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) [0x0001e] in <695d1cc93cca45069c528c15c9fdd749>:0 at MLAPI.Messaging.InternalMessageHandler.HandleChangeOwner (System.UInt64 clientId, System.IO.Stream stream) [0x00015] in <beeac23026c94eb3810572809f7f06dc>:0 at MLAPI.NetworkManager.HandleIncomingData (System.UInt64 clientId, MLAPI.Transports.NetworkChannel networkChannel, System.ArraySegment1[T] data, System.Single receiveTime, System.Boolean allowBuffer) [0x0020d] in :0
at MLAPI.NetworkManager.HandleRawTransportPoll (MLAPI.Transports.NetworkEvent networkEvent, System.UInt64 clientId, MLAPI.Transports.NetworkChannel networkChannel, System.ArraySegment`1[T] payload, System.Single receiveTime) [0x000cd] in :0
at MLAPI.NetworkManager.OnNetworkEarlyUpdate () [0x0007e] in :0
at MLAPI.NetworkManager.NetworkUpdate (MLAPI.NetworkUpdateStage updateStage) [0x00009] in :0
at MLAPI.NetworkUpdateLoop.RunNetworkUpdateStage (MLAPI.NetworkUpdateStage updateStage) [0x00021] in :0
at MLAPI.NetworkUpdateLoop+NetworkEarlyUpdate+<>c.b__0_0 () [0x00000] in :0

Expected outcome
I would expect that clients unaware of a given object do not receive any information sent by it.

Environment (please complete the following information):

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions