Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Error: "Size limitation on snapshot did not prevent all errors"

Discussion in 'NetCode for ECS' started by haxic, Sep 10, 2023.

  1. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    I'm encountering an error message during play mode: 'Size limitation on snapshot did not prevent all errors.' This issue seems to occur only when a certain number of ghost entities, around 60 or so, are present. When I have approximately 50 entities, I don't encounter any errors. However, after spawning an additional 10 or so, the error starts occurring roughly once a second.

    I have several components with ghost fields attached to my ghost entities, although only a few get updated frequently. I use prediction for player-owned ghost entities and interpolation for all other ghost entities.

    I'm using version 1.0.14 of Entities, Netcode for Entities, etc., and Unity 2022.3.0f1.

    What could be causing this error? Is it related to having too many ghost entities and/or ghost fields?

    Full stack trace:


    Size limitation on snapshot did not prevent all errors
    UnityEngine.Debug:LogError (object)
    Unity.Logging.Sinks.ManagedUnityEngineDebugLogWrapper:WriteFunc (Unity.Logging.LogLevel,byte*,int) (at ./Library/PackageCache/com.unity.logging@1.0.14/Runtime/TestSinks/UnityDebugLogSink.cs:154)
     
    Last edited: Sep 12, 2023
  2. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    Hey haxic! I can check in more detail tomorrow, but it looks like you may have one specific ghost which - when serialized - exceeds the max size of the UTP packet (including an automatic retry we perform with double capacity).

    Do you have a specific ghost with lots of large GhostFields? Or perhaps a huge IBufferElementData DynamicBuffer with a large count? The quantity of ghosts in the world should have no impact, it's a single ghost type causing the problem.
     
  3. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    Sorry for the late reply. I have encountered another issue that currently make me unable to view runtime data for some of my entities :S

    Until I have fixed that issue, I have a question about this:

    upload_2023-9-12_15-53-3.png

    Is it normal that the 'Snapshot Data Buffer' is that large?
     
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,029
    :eek: I just checked my project Snapshot Data Buffer.

    upload_2023-9-12_22-12-0.png
     
    haxic likes this.
  5. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    Yeah ok :D I think I read somewhere that the snapshot buffers got pretty large considering what they are used for. I was just uncertain about how large. I think my mere 9k is nothing to worry about when yours hit 90k+.
     
  6. haxic

    haxic

    Joined:
    Jul 12, 2021
    Posts:
    20
    I've identified the problematic ghost entity, but I'm struggling to understand why it's triggering the error. In my setup, I have a "base tank" prefab, which essentially represents the core body of a tank and includes all the necessary components for a basic tank "unit" in my game. Additionally, there are variations of this "base tank" that come with added sub-entities like turrets, barrels, etc. Strangely, I encounter the error when I spawn multiple instances of the "base tank", but this issue doesn't occur when I spawn the variant tank entities. The "base tank" barely got any ghost fields attached to it. Could some of my systems somehow affect something when handling these "base tank" entities?
     

    Attached Files:

  7. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    This sounds odd. Can you file a bug report with your repro project (ideally so we just have to press play and it'll repro), and post the IN-XXXX here, so we can take a look? Cheers.
     
  8. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    The snapshot data is not large by itself: it is 288 bytes. The data inside the snapshot (for memory alignment purpose) is all stored as Int (or long or float) even if you have a byte or bool in your struct and the values of that field are using way less than 32 bits.
    So it is not representative of the data sent to the network, The SnapshotDataBuffer is > 9K because it store 32 slot.

    Also, just to clarify any doubt: the fact you may have a snapshot data of 2K (for a single ghost) does not imply this is the compressed size (that can be way less, given the Huffman compression). Delta compression is also reducing that quite substantially, so keep that in mind.

    In case of very large single-entity snapshot size, we may not being able to send a single entity over the network using the unreliable pipeline (especially before delta compression kick-in, that is after we receive the ack from the client) and in that case we switch and use use fragmentation instead. By default, this can go up to 4k bytes, so more than enough for this specific case.

    Also, to make understand even more what there is inside, the snapshot does not contains only the entity data, there are multiple pieces composing it:
    - Spawn/Despawn list,
    - Ghost headers (ghost type, baselines, ghost id, change masks, enable bits mask, compressed component size)
    - Component data itself
    - other little bits.

    If, for some reason, usually for large ghost archetypes, we can't fill even a single entity in the fragmented pipeline we indeed trigger errors.
    But this does not look like the case.

    From inspector picture, looks like to me you are using pre-spawned ghosts (you have instances of these ghost in the sub-scene). Does not look like you are spawning actually a prefab. That is not correct in general (this can really cause strange issues, and that may be one of the reason).

    It is plenty possible we have also just a corner case bug on our end, so as @NikiWalker suggests, open a case for this.