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

2.0.0-exp2 Distributed Authority has some undue GC every frame #2891

Open
Yoraiz0r opened this issue Apr 21, 2024 · 0 comments
Open

2.0.0-exp2 Distributed Authority has some undue GC every frame #2891

Yoraiz0r opened this issue Apr 21, 2024 · 0 comments
Assignees
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report

Comments

@Yoraiz0r
Copy link

Description

In NGO 2.0.0-exp2, simply enabling "distributed authority" in the network manager's session mode results in garbage allocation every frame.

The issue occurs under NetworkSpawnManager.DeferredDespawnUpdate, due to closure of currentTick near the end of the method.

Reproduce Steps

  1. Create a blank scene with NGO version 2.0.0exp2
  2. Add a network manager, and set its session mode to "distributed authority"
  3. Enter playmode
  4. Open the profiler and witness that the GC per frame is "20"
  5. Exit playmode
  6. Change the network manager's session mode to "client server"
  7. Enter playmode
  8. Witness that GC per frame is "0"

Actual Outcome

GC per frame with distributed authority is 20

Expected Outcome

GC per frame with distributed authority is 0

Environment

  • OS: Windows 10
  • Unity Version: 6000.0.0b13
  • Netcode Version: 2.0.0-exp2
  • Netcode Commit: e7ac3c8

Fixing this

Change the following code from this:

            var despawnObjects = DeferredDespawnObjects.Where((c) => c.TickToDespawn < currentTick).ToList();
            foreach (var deferredObjectEntry in despawnObjects)
            {

To this:

            foreach (var deferredObjectEntry in DeferredDespawnObjects)
            {
                if (deferredObjectEntry.TickToDespawn >= currentTick)
                {
                    continue;
                }
@Yoraiz0r Yoraiz0r added stat:awaiting triage Status - Awaiting triage from the Netcode team. type:bug Bug Report labels Apr 21, 2024
@Yoraiz0r Yoraiz0r changed the title 2.0.0-exp Distributed Authority has some undue garbage allocation every frame 2.0.0-exp2 Distributed Authority has some undue garbage allocation every frame Apr 21, 2024
@Yoraiz0r Yoraiz0r changed the title 2.0.0-exp2 Distributed Authority has some undue garbage allocation every frame 2.0.0-exp2 Distributed Authority has some undue GC every frame Apr 21, 2024
@fluong6 fluong6 added stat:import priority:high stat:imported Issue is tracked internally at Unity and removed stat:awaiting triage Status - Awaiting triage from the Netcode team. stat:import labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:high stat:imported Issue is tracked internally at Unity type:bug Bug Report
Projects
None yet
Development

No branches or pull requests

3 participants