Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Bug IN-76895: WebGL Client Hash Not Matching Linux Server Hash

Discussion in 'NetCode for ECS' started by slickgotchi, May 23, 2024.

  1. slickgotchi

    slickgotchi

    Joined:
    Jun 26, 2022
    Posts:
    28
    Hi,

    When running a WebGL build with netcode for entities I get the below two errors (at end of the post) in the browser inspector console and cannot proceed. I believe the second error is more critical as it is to do with a hash mismatch between server and client. I have tried to rectify this with the fix at the below linked issue but it does not work. I have checked every .asmdef in my project and none are excluding assemblies based on the build being WebGL (There was one in Unity.Transport.Networking.Samples.Crossplay.asmdef but I removed the defineConstraint for that).
    Unity Issue Tracker - Ghost Hash from the Server side doesn't match the Ghost Hash on Client side (unity3d.com)

    I have reproduced the errors at the below basic project link and included steps on getting the local server instance up and running.
    slickgotchi/BasicNetcodeWebGame: Trying to get Netcode for Entities working with WebGL Builds (github.com)
    @CMarastoni if I could get any help with this that would be hugely appreciated. I've spent a good number of weeks trying to get this to work and it would be massive for our project if I can get it working!

    I have also raised this through bug reports under issue IN-76895.

    This is the first error
    Code (CSharp):
    1. NotSupportedException: To marshal a managed method, please add an attribute named 'MonoPInvokeCallback'
    2. to the method definition. The method we're attempting to marshal is:
    3. Unity.NetCode.ComponentSerializationHelper`3[[Unity.Physics.PhysicsVelocity,
    4. Unity.Physics, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],
    and this is the second more problematic error
    Code (CSharp):
    1. 9f0ebc4b-d105-4b8d-87a3-a37962b7ea7d:9  Received a ghost - EN_Player - from the server which
    2. has a different hash on the client (got 6806886325826531417 but expected 10301392053713532870).
    3. GhostPrefab: Entity(139:1) ('')
     
    Last edited: May 27, 2024
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    966
    Ohh!! Thanks for reporting! We will check this out
     
    slickgotchi likes this.
  3. slickgotchi

    slickgotchi

    Joined:
    Jun 26, 2022
    Posts:
    28
    Thank you! Please let me know if you need any more info on my setup.
     
  4. slickgotchi

    slickgotchi

    Joined:
    Jun 26, 2022
    Posts:
    28
    Hi @CMarastoni, have you had a chance to look into this issue and any thoughts on what might be causing the hash mismatch? If not, do you know when yourself and the team will get a chance to investigate?
     
  5. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    966
    Hey,
    Sorry not yet! I will investigate briefly.
     
    slickgotchi likes this.
  6. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    966
    the first is due to a problem with WebGL code-stripping. Please set the stripping level to minimal

    the second problem is due to the fact editor and client have different set of RPCs (because we also include test assemblies).
    The solution is to actually enforce using the RpcCollection.DynamicAssembly (for example inside a System.OnCreate) so that the protocol is not enforce for dev builds and instead RPCs are validated when they are received.

    We have documentation about it here: Networked Cube | Netcode for Entities | 1.2.3 (unity3d.com)