Skip to content

fix: NetworkTransport early and post late updates #3113

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

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Oct 31, 2024

This PR improves upon UnityTransport's oder of operation when it comes to:

  • Processing new connections at the beginning of the frame.
    • This used to happen within the update stage.
  • Process transport events before NetworkBehaviour updates but after NetworkTimeSystem has been updated for the current frame.
    • This used to happen within the update stage.
  • Flush send queued outbound messages at the end of the frame.
    • This used to happen on next frame and within the update stage.

Changelog

  • Fixed: If you update multiple packages, create a new section with a new header for the other package.

Testing and Documentation

  • Includes updates to UnityTransportTests.
  • No documentation changes or additions were necessary.

Break out the UnityTransport's Update method into two methods: EarlyUpdate and PostLateUpdate.
Modifications to NetworkManager to invoke the newly adding EarlyUpdate and PostLateUpdate methods.
Adjusting the job handle name.
Migrating the m_FlushSendJobHandle.Complete(); outside of the driver IsCreated check to avoid any potential job safety issues.
removing unused Update method and removing the Unity.Netcode.Transports.UTP namespace reference.
Removing the job handle stuff as that could potentially break users trying to get RTT during OnGUI.
Adjusting the UnityTransport tests to simulate the NetworkManager invoking the EarlyUpdate and PostLateUpdate methods.

Adding event processing in shutdown primarily for integration testing to handle any pending events prior to shutting down the transport.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review October 31, 2024 22:02
@NoelStephensUnity NoelStephensUnity requested review from a team as code owners October 31, 2024 22:02
This resolves the issue with the UnitTransportConnectionTests failing in areas where it was just waiting and not invoking the EarlyUpdate and PostLateUpdate methods.
Another pass trying to fix what seems to be a possible timing issue.
Approaching the issue differently by adding a UnityTransportTestComponent that registers with the playerloop update stages needed to properly handle message processing.
Removing the unused additional script and namespace reference.
removing some more unused code and the namespace reference.
removing some CRs and unused local var.
Removing whitespace issue.
Setting velocity to zero after moving and after waiting.
Splitting up accepting a connection and process event.
Migrating process event into the PreUpdate but after time has updated.
Minor test clean up and adjustments.
Experimenting with adjusting when transport adds inbound messages to the NGO inbound queue relative to when time is updated and NGO's inbound messages are processed.
adjusting transform ownership test slightly.
removing white space.
Tracking down the timing issue with this test.
Reverting back to both new connections and messages processing in EarlyUpdate and adding additional debug info to ownership test that keeps failing.
Exposing the added early update and post late update methods so custom NetworkTransport implementations can take advantage of them.
Added additional xml API documentation for clarity.
I believe this will fix the issue with the DA failures in the ownership teats.
Updated UnityTransportTestHelpers to match recent adjustments.
Fixing an issue with the base invocation.
Adding change log entries.
Found the culprit with the transform ownership instability. Moving an object can give it velocity which if there is enough time that passes between updates then fixed update will apply enough velocity motion to move the object and it will continue to move.
Increased mass and linearDampening and setting the linear velocity to zero in the appropriate places.
@NoelStephensUnity NoelStephensUnity merged commit 789f375 into develop-2.0.0 Nov 6, 2024
24 checks passed
@NoelStephensUnity NoelStephensUnity deleted the fix/networktransport-early-and-postlate-updates branch November 6, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants