Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Bug Badly Generated Code for GhostComponentSerializer for data using > 64 ChangeMaskBits

Discussion in 'NetCode for ECS' started by Jawsarn, Sep 12, 2023.

  1. Jawsarn

    Jawsarn

    Joined:
    Jan 12, 2017
    Posts:
    245
    SerializeSnapshot & Deserialize increase the startOffset and decrease ChangeMaskBits by 32 only once as it calls GhostComponentSerializer.CopyFromChangeMask to get the correct changeMask resulting in badly serialized data. It should increase it after every call resulting in 32->64->96 offset. CalculateChangeMask seems to be doing this correctly.
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    891
    IIRC correctly we recently fixed that issue, but I may have understood that incorrectly.
    The generated code for the serialiser does not increment the startOffset itself, but introduce every 32 change mask bits something like:
    Code (csharp):
    1.  
    2. GhostComponentSerializer.CopyFromChangeMask(
    3. changeMaskData, startOffset + __GHOST_CHANGE_MASK_BITS__, ChangeMaskBits - __GHOST_CHANGE_MASK_BITS__)
    4.  
    The __GHOST_CHANGE_MASK_BITS__ is actually the incrementing variable (32,64,96...)

    Se a generated serialiser looks like:

    Code (csharp):
    1.  
    2. var changeMask.= GhostComponentSerializer.CopyFromChangeMask(changeMaskData, startOffset, ChangeMaskBits)
    3. if(xxx..)
    4.   dataStream.Write(..)
    5. ...
    6. //after 32 change bits
    7. changeMask = GhostComponentSerializer.CopyFromChangeMask(changeMaskData, startOffset + 32, ChangeMaskBits - 32);
    8.  
    Can you please copy here the code of one of these generated ghost serialiser that are incorrectly handling this? Even better if you can open a case for this.
     
  3. Jawsarn

    Jawsarn

    Joined:
    Jan 12, 2017
    Posts:
    245
    Correct, in SerializeSnapshot and Deserialize the __GHOST_CHANGE_MASK_BITS__ only does the first 32, and does not increment to 64,96 etc.

    If you still need a case I'll try make a small project and submit at end of day.
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    891
    which version of Netcode for Entities are you using? (just to be sure) The latest one?
     
  5. Jawsarn

    Jawsarn

    Joined:
    Jan 12, 2017
    Posts:
    245
    I'm on 1.0.15, I didn't see the new version. Do you know if it would be fixed in that one? It did not specify in change log.
     
  6. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    891
    I confirm the bug still exist and will be fixed as soon as possible.
     
  7. Jawsarn

    Jawsarn

    Joined:
    Jan 12, 2017
    Posts:
    245
  8. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    891
    yeah! It has been already resolved.
     
    Jawsarn likes this.