colyseus-unity-sdk: v0.14 : KeyNotFoundException: The given key was not present in the dictionary.
I receive a key not found at https://github.com/colyseus/colyseus-unity3d/blob/master/Assets/Plugins/Colyseus/Serializer/Schema/ReferenceTracker.cs#L51
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <9577ac7a62ef43179789031239ba8798>:0)
Colyseus.Schema.ReferenceTracker.Remove (System.Int32 refId) (at Assets/Plugins/Colyseus/Serializer/Schema/ReferenceTracker.cs:51)
Fields generated by the last version of c# generator (original version)
Version : colyseus server : 0.14.4 colyseus unity : 0.14.2 schema : 1.0.6
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 21 (5 by maintainers)
Commits related to this issue
- fix bad refs.Remove() calls due to ArraySchema#GetByIndex issue. #133 — committed to colyseus/colyseus-unity-sdk by endel 3 years ago
Hey, @endel I made a fork from colyseus-unity3d and implemented the behavior to trigger the bug.
it’s a card game you start with 52 cards and every time you click to play the cards button it plays 1 to 3 cards randomly if you hit it many times (e.g. once per second) it will trigger the bug before the remaining cards hit zero.
Repo: forked repo (card game)
Thanks!
Thank you, @Unelith this is helpful info!
@mitchLucid Perhaps extra details could be useful then:
ArraySchemaholds instances of anAreaStateSchema, whose definition is as follows:AreaStateschema instance from eitherOnAddorOnRemovelistener attached to theArraySchema, I do pass it around quite a lot, for instance:Which in turn calls this:
@Unelith I will try to look into this soon but if it was fixed in the update it was done incidentally, so I wouldn’t begin migrating your project on that hope quite yet. I will try to set up a good repro case locally and test with the updated SDK to confirm one way or the other
@lee-orr can you share a snippet of the code deals with those operations and a snippet of your object with map schemas? If we can it will be easier for @endel to fix the bug on MapSchema
I’m getting the same issue, and then next time I try to update the same object I end up with:
I have a large object (containing a bunch of MapSchema’s) that I replace when this happens. Generally the first replacement will cause this but seem to work, while the second one doesn’t. I also tried instead of placing this object in a Map itself, deleting the old one and adding the new one in a new key - but it still causes the exact same issue. For me this is breaking - this object contains the building blocks for user-created maps, and without being able to update them & replace them I am completely stuck.