question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Key already exists exception when enter play mode options is on in 1.5.2

See original GitHub issue

Description

A blank unity project with enter play mode options enabled and domain reload off, throws an exception for every network behavior in the project.

The stack-trace highlights even built in network behaviors like networkanimator or networktransform.

ArgumentException: An item with the same key has already been added. Key: 1665640498
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <eef08f56e2e042f1b3027eca477293d9>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <eef08f56e2e042f1b3027eca477293d9>:0)
Unity.Netcode.Components.NetworkAnimator.InitializeRPCS_NetworkAnimator () <0x26f88a73b30 + 0x000ca> in <b476fa4747044164bbf4bd8f8f4d4d2e>:0

A clear and concise description of what the bug is.

Reproduce Steps

  1. Create a blank unity project in 2022.3.5f1 (URP core)
  2. Install netcode for game objects version 1.5.2
  3. Install parallel sync via github link https://github.com/VeriorPies/ParrelSync.git?path=/ParrelSync
  4. Go to project settings and enable “Enter Play Mode Options”, ensure that “Reload Domain” is off.
  5. Enter play mode once, then exit.
  6. Enter play mode again and 2 exceptions should appear. One for NetworkTransform and one for NetworkAnimator.

Actual Outcome

No error

Expected Outcome

One exception for each networkbehavior in the project.

Screenshots

image

Environment

  • OS: Windows 10
  • Unity Version: 2022.3.5f1
  • Netcode Version: 1.5.2

Additional Context

Error does not appear if the netcode version is downgraded to 1.4.0, or 1.5.1

Issue Analytics

  • State:open
  • Created 2 months ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
NoelStephensUnitycommented, Aug 2, 2023

I think I see where we could avoid this issue. Since the domain is not getting reloaded the RPC dictionary is not being cleared on the codegen/ILPP side of things. This does seem to be a potential regression bug and will investigate the more recent updates to the RPC table generation.

0reactions
Xajaxajacommented, Aug 2, 2023

I understand that, but it has worked for all previous versions of NGO, why would it stop working with this version?

Also even though the error is there, the game works perfectly fine, RPCs work etc. Basically the error doesn’t stop the code from working, so it seems like an issue that could be handled. Even if there might be special cases where it would not work.

Also enter play mode is such an improvement to workflow that if you need to enable domain reload to play test, it’s almost a deal-breaker by itself.

It should at least be investigated to see if there are any workarounds.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configurable Enter Play Mode
We profiled and analyzed Enter Play Mode to understand where the time is spent. As a result, we would like to offer options...
Read more >
Issues · Unity-Technologies/com.unity.netcode.gameobjects
New "Writing past the end of the buffer" issue in 1.5.1/1.5.2 (worked in 1.4.0) ... Key already exists exception when enter play mode...
Read more >
ArgumentException: An element with the same key already ...
You are trying to add an existing key to a Dictionary . The first error in the Awake function from the ManagerChat script...
Read more >
Manual: Configurable Enter Play Mode
To configure the Enter Play Mode settings, go to Edit > Project Settings > Editor and enable Enter Play Mode Options. When you...
Read more >
Why do I keep getting an exception about "an element with ...
In the innermost loop of Start() , you're trying to add objectPool to the poolDictionary using pool.tag as the key.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found