Skip to content

fix: client writing to netvar error #468

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

Merged
merged 5 commits into from
Mar 29, 2022

Conversation

LPLafontaineB
Copy link
Contributor

@LPLafontaineB LPLafontaineB commented Feb 7, 2022

Description (*)

From some investigation I found that there exists certain cases that lead to the OnNetworkSpawned method to be called on NetworkBehaviors a few frames after their Awake and Start happened. These cases are during the client synchronization process, when late joining, if there are multiple additive scenes to load and the NetworkObject that this NetworkBehavior is attached to is placed in-scene in one of those scenes, except the last one to be loaded. In those cases, OnNetworkSpawned is called on all in-scene placed objects only after all additive scenes are loaded, which leads to this delay for the NetworkObjects in the first scenes to load.

Related Pull Requests

Issue Number(s) (*)

Fixes issue(s): MTT-2921

Manual testing scenarios

I could not reproduce the specific issue this PR addresses, but I tested that these changes make it so the NetworkBehavior's Update or FixedUpdate are never called on clients in the cases mentioned in the description and that it works properly as before on the host.

Questions or comments

If this fix is approved, I think it should also be applied to our other NetworkBehaviors that should only execute on the server.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@LPLafontaineB LPLafontaineB added the 1-Needs Review PR needs attention from the assignee and reviewers label Feb 7, 2022
@SamuelBellomo SamuelBellomo added the 0-URGENT Blocker for a release and needs to be merged ASAP label Feb 7, 2022
@SamuelBellomo SamuelBellomo removed the 0-URGENT Blocker for a release and needs to be merged ASAP label Feb 7, 2022
@SamuelBellomo
Copy link
Contributor

removing urgent label, let's fix this properly. This shouldn't block this release

@LPLafontaineB LPLafontaineB added 4-On Hold PR can't proceed because it's blocked or is otherwise waiting on something. and removed 1-Needs Review PR needs attention from the assignee and reviewers labels Feb 10, 2022
@LPLafontaineB
Copy link
Contributor Author

Put on hold waiting for PR #477

@LPLafontaineB LPLafontaineB added 1-Needs Review PR needs attention from the assignee and reviewers 2-Easy This PR is trivial and can be reviewed quickly and removed 4-On Hold PR can't proceed because it's blocked or is otherwise waiting on something. labels Mar 28, 2022
@LPLafontaineB
Copy link
Contributor Author

removed OnHold label as PR #477 is postponed

@NoelStephensUnity
Copy link
Contributor

NoelStephensUnity commented Mar 28, 2022

Just an FYI:
PR-1785 cleans up how and when properties are set. You can now rely upon "IsSpawned" without having to have a local variable to keep track during OnNetworkSpawned.
So this should work fine now:

private void FixedUpdate()
{
    if (!IsSpawned)
    {
        return;
    }
    ...//Rest of the code
}

@fernando-cortez fernando-cortez added 2-One More Review One review in, one to go and removed 1-Needs Review PR needs attention from the assignee and reviewers labels Mar 29, 2022
@SamuelBellomo SamuelBellomo removed the 2-One More Review One review in, one to go label Mar 29, 2022
@LPLafontaineB LPLafontaineB merged commit 7d0b689 into develop Mar 29, 2022
@LPLafontaineB LPLafontaineB deleted the fix/client-writing-to-netvar-error branch March 29, 2022 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2-Easy This PR is trivial and can be reviewed quickly 3-Good to Merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants