xenko icon indicating copy to clipboard operation
xenko copied to clipboard

GameSystemCollection.Remove doesn't remove item from underlying updateableGameSystems and drawableGameSystems lists

Open guygodin opened this issue 7 years ago • 4 comments

The AddGameSystem call specifies a ProfilingKey as the KeyValuePair.Value while the Remove call specifies null as the value; therefore the item doesn't get removed.

https://github.com/SiliconStudio/xenko/blob/6fca455a2d67f6f53fc1c7ad8c3722938b3b9a56/sources/engine/SiliconStudio.Xenko.Games/GameSystemCollection.cs#L331

https://github.com/SiliconStudio/xenko/blob/6fca455a2d67f6f53fc1c7ad8c3722938b3b9a56/sources/engine/SiliconStudio.Xenko.Games/GameSystemCollection.cs#L343

guygodin avatar Apr 13 '18 04:04 guygodin

First of all, congrats for the #666 issue :smiling_imp:

Secondly, could you update the description and provide a link to the related file(s) in the sources?

Kryptos-FR avatar Apr 13 '18 05:04 Kryptos-FR

Woah wicked! Links added to issue.

guygodin avatar Apr 13 '18 05:04 guygodin

More info regarding this issue:

The AddGameSystem call specifies a ProfilingKey as the KeyValuePair.Value

https://github.com/SiliconStudio/xenko/blob/6fca455a2d67f6f53fc1c7ad8c3722938b3b9a56/sources/engine/SiliconStudio.Xenko.Games/GameSystemCollection.cs#L390

Also, according to this answer, "[A KeyValuePair] is a struct. This means it uses the default value equality. This simply compares the values of the fields to test for equality." So, this is almost certainly a bug.

Lastly,updateableGameSystems is a normal C# list instead of a seemingly more fitting dictionary?

stefnotch avatar Apr 13 '18 12:04 stefnotch

It should be a list since it is iterated over a lot (iterating over lists performs better than dictionaries). The solution is to iterate over the items of the list in the Remove method and check for KeyValuePair.Key equality like it’s done elsewhere in my opinion.

guygodin avatar Apr 13 '18 15:04 guygodin