Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: NetworkTransform synchronization fixes and owner authoritative performance improvement on server-host [MTT-6971] #2636

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Jul 22, 2023

This PR address the following issues:

  • When an owner authoritative client uses half precision with position synchronization, it was possible for the server-host to forward the owner's state updates with already processed NetworkDeltaPosition values.
    • This could cause visual anomalies on non-authoritative remote clients during the collapsing of the position delta into the total local position.
  • Due to the non-guaranteed spawn order of NetworkObjects, scale synchronization could potentially not synchronize properly if the child NetworkObject had not yet been parented.
    • Now NetworkTransform will send both local and lossy scale values if scale synchronization is enabled during teleporting and/or the initial synchronization and the NetworkObject is parented. The receiver determines which to apply based on whether the receiver's instance is parented yet (or not) and whether world position stays was used when the NetworkObject was parented.
  • NetworkTransform no longer uses NetworkVariables for updating transform state due to the processing cost when updating owner write permission NetworkVariables on the server-host.
    • The NetworkVariable serialization cost of owner authoritative NetworkTransforms was:
      • The deserialization on the server-host side at the beginning of the frame
      • The re-serialization cost for each connected client at the end of the frame
    • With the switch over to named messages, the serialization cost of owner authoritative NetworkTransforms is now:
      • The deserialization on the server-host side at the beginning of the frame
        • The named message payload is forwarded just prior to the host deserializing.

MTT-7057
MTT-7056
MTT-6971

fix: #2628
fix: #2639

Changelog

  • Fixed: Issue with client synchronization of position when using half precision and the delta position reaches the maximum value and is collapsed on the host prior to being forwarded to the non-owner clients.
  • Fixed: Issue with scale not synchronizing properly depending upon the spawn order of NetworkObjects.
  • Fixed: Issue position was not properly transitioning between ownership changes with an owner authoritative NetworkTransform.
  • Fixed: Issue where a late joining non-owner client could update an owner authoritative NetworkTransform if ownership changed without any updates to position prior to the non-owner client joining.

Testing and Documentation

  • Includes new and updated integration tests.
  • No documentation changes or additions were necessary.

This resolves an issue with half float precision not synchronizing properly when running in owner authoritative mode, the owner client sends an update to the host-server, the host-server then forwards the state update to the remaining clients at the end of the frame but during the initial processing of the state update the delta position value is collapsed into the full float position due to exceeding the maximum delta. The primary issue was the order of operations that occurred using NetworkVariables to update the transform state when in owner authority mode.

This also reduces the amount of serialization and processing a host has to perform when receiving owner authoritative updates and there are 2 or more remote clients connected (i.e. it has to forward the result to the other clients).  Now, it just forwards the message payload to the non-owner clients upon receiving the state update.
This fixes an on-going issue with scale where really the answer was to send both the lossy and local scale values when synchronizing and/or teleporting and letting the client-side determine which to use depending upon whether the NetworkObject was parented, was the parenting applied when applying the states, and whether the parenting used WorldPositionStays.

This also fixes some minor issues with the parenting test not checking if the NetworkObject was parented before testing the final values.

This also updates named message handling slightly so it doesn't spam the log console during shutdown if there are incoming messages while shutting down.
removing white spaces.
Removed unused namespace.
Simplified the NetworkTransformState constructor and assignment within OnSynchronize.
Putting the original OnInitialize method with the NetworkVariable parameter to avoid issues with validation.
removing white spaces
removing commented out code
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review July 24, 2023 22:12
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner July 24, 2023 22:12
Setting the correct value for IsParented flag.
Adding internal BitSet setter and getter for testing.
Adding NetworkTransformStateFlags test to validate the NetworkTransformState flags.
resolves an issue where you have an owner authoritative NetworkTransform and a host-server with two remote clients connected and the following sequence occurs:
- Client A connects to the host first and takes ownership of a NetworkObject but does not change the transform state.
- Client B connects and attempts to move the NetworkObject that Client A owns
- Client B was able to move the NetworkObject

The code removed was no longer needed with this PRs parenting adjustments.
This test adds a "sub-child" (NetworkObject parented under a child) to the parenting test to add the additional check and make sure that all nested children preserve their values when changed for connected clients and those changes are applied and preserved for late joining clients.
Adding a test to verify that when a late joining client is connected after ownership has been transferred from the host-server to an already connected client and the owner authoritative transform has not changed yet that the non-owner client cannot change the transform values.
removing added CR
@NoelStephensUnity NoelStephensUnity changed the title fix: NetworkTransform synchronization fixes and owner authoritative performance improvement on server-host fix: NetworkTransform synchronization fixes and owner authoritative performance improvement on server-host [MTT-6971] Aug 1, 2023
updating change log entries.
@NoelStephensUnity NoelStephensUnity merged commit 422aa23 into develop Aug 1, 2023
23 checks passed
@NoelStephensUnity NoelStephensUnity deleted the fix/networktransform-owner-authority-halfprecision-nonowner-sync branch August 1, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants