NetworkList duplicated entries on clients

Hey guys! Im trying to implement network lists and for some reason clients are getting duplicated data.
My list is a networklist of a simple struct

[System.Serializable]
public struct ShipPart : INetworkSerializable, IEquatable<ShipPart>
{
    public FixedString128Bytes ID;
    public int Index;
    public int CurrentArmorPoints;
    public int MaxArmorPoints;

    public bool Equals(ShipPart other)
    {
        return other.ID == ID;
    }
    public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
    {
        serializer.SerializeValue(ref CurrentArmorPoints);
        serializer.SerializeValue(ref MaxArmorPoints);
        serializer.SerializeValue(ref ID);
        serializer.SerializeValue(ref Index);
    }
}

and as you can see on the following screenshots, the server has the correct amount of elements but the client has duplicated data:
Server:
9547438--1348921--upload_2023-12-25_13-33-39.png
Client:
9547438--1348924--upload_2023-12-25_13-33-56.png

The data is added on the server on networkSpawn of the ship and i was able to consistently reproduce this via the following steps:
1: Host
2: Client joins
3: Server spawns networkobject and on spawn populates the list

After this, data is desynced between server and client.
Does anybody know why this is happening andhow to solve it?

Does anybody use network list with structs?

I’ve used them in the past and I had a recollection of seeing duplicated network list data on the client. I did some searching and I mentioned it here, it may not be related to your problem as that seemed to be triggered by a network variable change.

It might be worth creating a Github issue on it, especially if you can reproduce it in a small project.

oh… thats sad, ill see about creating a github issue in the near future.
in the meantime, what do you use instead? say you need a list of objects that are not necesarelly networkobjects, like maybe a list of ship parts?
thanks for your reply :slight_smile: !

I’d stick with what you’re doing if you’re happy with it and try figure out the issue. Network lists were reliable last time I checked so it would be good to work out what’s wrong as it sounds like a bug that needs fixing.

I did try replicate what it sounds like you’re doing but I don’t see the issue. You might have to create that small project or share enough of the project setup and code to be able to reproduce it.

1 Like

Will do, thanks m8!

@Complex77
Not sure if this will help you, but I put together a quick (simple) example of using NetworkLists for another user and you might find this project useful for either creating a replication of the issue you are experiencing or tracking down what the issue might be on your end.

Also:

  • The INetworkSerializable looks fine to me… so you might provide the script that adds the parts and is logging the information.
  • Also, make sure there isn’t any form of static list (or NetworkList for sure) getting both the host and client’s parts.

9567916–1353790–NetworkVarExample.zip (45.7 KB)

1 Like

Ok, will do so. I did another project to test network lists and I was not able to replicate the issue.
I’ll head back to where my code is breaking to try to understand why they desync.
Thanks guys