Skip to content

feat: snapshot spawn pre-requisite 2 #1192

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 32 commits into from
Sep 16, 2021

Conversation

jeffreyrainy
Copy link
Contributor

This separates the spawning of NetworkList from the value updates. It adds a "full" event to the NetworkList which consists of sending the whole list. It gets performed when the variable is marked dirty.

We also add a mechanism to mark all the NetworkVariables of an object dirty and remove the serialization of the NetVars with the spawn command.

The HiddenVariable test is also modified to not rely on the count of events, but rather on the actual values after each step of the test. This is better because it tests the right thing, but also because it allows for timing differences. The spawn could occur before the value update or simultaneously. As such, relying on the count of events would be incorrect.

jeffreyrainy and others added 30 commits September 9, 2021 10:09
…date. Helps pinpointing the issue with snapshot enabled
This fixes the issue with the UnityTransport updates breaking the ability to still use UNetTransport.
Just minor refactoring of when we actually need the ENABLE_RELAY_SERVICE define.
Also some cleanup.
removing the InputField pefab.
unpacked this inside of the ConnectionModeButtons prefab.
updated SampleScene to reflect this change
updating comments
…e-buttons' into feature/enable-snapshot-spawn
@@ -73,10 +73,20 @@ public override bool IsDirty()
public override void WriteDelta(Stream stream)
{
using var writer = PooledNetworkWriter.Get(stream);

if (base.IsDirty())
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problably stupid question because I'm misunderstanding this. But this causes the full list to be serialized to all connected clients whenever IsDirty is set to true? Wouldn't that happen too often? E.g. when:

  • An item is added / removed from the list
  • The object becomes visible on any client.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the first point, my understanding is that NetworkList.Add() will do:

            m_List.Add(item); // add to the underlying container

            var listEvent = new NetworkListEvent<T>()  {
                Type = NetworkListEvent<T>.EventType.Add,
...            }; // create an event

            HandleAddListEvent(listEvent); // handle the event
        }

This then does:

        private void HandleAddListEvent(NetworkListEvent<T> listEvent)
        {
            m_DirtyEvents.Add(listEvent);
            OnListChanged?.Invoke(listEvent);
        }

and as such does not mark the list dirty. So, dirty means: needs complete refresh, and m_DirtyEvents means need incremental changes.

On the second point, yeah. There's a price to pay here. But until AoI is integrated and we start automatically hiding/showing object, I think these will be very infrequent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay yeah that makes sense

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I follow, but would add:

  • please add a comment to the effect of "IsDirty means totally dirty, else m_DirtyEvents means incremental
  • but I have a hunch this will bite us and should be re-visited

Copy link
Contributor

@LukeStampfli LukeStampfli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were going to remove NetworkShow/Hide in this release?

@jeffreyrainy
Copy link
Contributor Author

jeffreyrainy commented Sep 16, 2021

I thought we were going to remove NetworkShow/Hide in this release?

We can only(reasonably) do that once we have AoI. The theory is that even though the whole show/hide mechanism has technical debt, the API itself is reasonable. So, when proper AoI-based show/hide drops in, the NetworkShow/NetworkHide API becomes an helper mechanism with AoI.

e.g.: User can put rules, like "hide zombies that are far and not green, but not from my team" via AoI, but also "Hide this Zombie for this player, I know what I'm doing" via NetworkHide.

Copy link
Contributor

@LukeStampfli LukeStampfli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still a bit confused because I thought we rip out the visibility system @mattwalsh-unity but the PR itself here looks good.

@jeffreyrainy jeffreyrainy merged commit 80913c1 into develop Sep 16, 2021
@jeffreyrainy jeffreyrainy deleted the feature/enable-snapshot-spawn-pre2 branch September 16, 2021 14:34
SamuelBellomo added a commit that referenced this pull request Sep 16, 2021
…am/feature/client-network-transform

* sam/feature/interpolation-for-network-transform:
  feat: snapshot spawn pre-requisite 2 (#1192)
  removing useless meta files
mollstam pushed a commit to Keepsake-Games/com.unity.netcode.gameobjects that referenced this pull request Feb 13, 2023
* feat: snapshot. Enabling spawns via snapshot by default

* feat: snapshot. Fixing the snapshot spawns mechanism to not rely on Singleton

* feat: snapshot. Removing the default on for snapshot spawns

* test: adjusted HiddenVariableTests to separate spawning from value update. Helps pinpointing the issue with snapshot enabled

* fix

This fixes the issue with the UnityTransport updates breaking the ability to still use UNetTransport.

* refactor

Just minor refactoring of when we actually need the ENABLE_RELAY_SERVICE define.
Also some cleanup.

* refactor

removing the InputField pefab.
unpacked this inside of the ConnectionModeButtons prefab.
updated SampleScene to reflect this change

* style

updating comments

* chore: removal of EnableNetworkVariable in NetworkConfig. It's always True now

* feat: snpashot enabled. Marking variables as dirty instead of serializing them with spawn command

* fix: this bool write cannot be remoed yet

* feat: snapshot spawn. Improving test, and re-enabling

* feat: snapshot. Pre-requisite to enabling snapshot spawns. Separating spawn from value updates for NetworkList

* style: standards.py fix, removing useless using directive

Co-authored-by: NoelStephensUnity <73188597+NoelStephensUnity@users.noreply.github.com>
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.

4 participants