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.

Bug in World Subscription / Serialization functionality?

See original GitHub issue

I’m not sure if it’s a bug or if I’m doing something horribly wrong-- please correct me if necessary.

I’m using the integrated TextSerializer to serialize and deserialize the complete state of my application, and it has been working without problems. At some point though I decided to use World.SubscribeComponentChanged<T>(foobar) to implement a callback mechanic. I made some quick tests, and the callback mechanic was working just fine. Unfortunately, it broke the serialization mechanic.

The serializer throws an exception and complains about duplicate key entries for each component I register with SubscribeComponentChanged. If I don’t subscribe, everything’s working fine again.

Maybe I’m doing something wrong, I don’t know. Disposing the subscriptions before serialization doesn’t help either, and I couldn’t find any relevant information in the documentation.

Can anybody reproduce this issue?

EDIT

To clarify what I’m trying to do here… I want to be notified whenever an entity is changed. I haven’t found a way to implement this other than using World.SubscribeComponentChanged<T>(foobar). I guess I could also explicitly add an UpdateComponent or whatever to the entity whenever I change one of its components and create a dedicated system to react properly, but I’d prefer the implicit solution as it would be cleaner and much less error-prone in my opinion.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
flomarcommented, Aug 26, 2021

You already fixed it? Great! 😃

And you already updated the NuGet package to 0.16.2? Damn… you’re fast.

Glad I could help.

I already removed all that UpdateComponent crap I added to my application code yesterday. I invoke World.SubscribeComponentChanged now using generics with each and every component type I do have in my code base, and everything works as intended-- most of all the serialization no longer throws an exception.

Thank you very much!

0reactions
Dorakucommented, Aug 26, 2021

Thx for the small repro, I don’t understand how it slipped past me and didn’t fail earlier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kotlin object + Serialization might cause bugs
TL;DR. Whenever we see kotlin object + Serializable then treat it as red flag and take extra caution with any of above solution....
Read more >
Deserialization - HackTricks
Serialization is the process of turning some object into a data format that can be restored later. People often serialize objects in order...
Read more >
Serialization&Deserialization Attacks | by zer0dac
Serialization means transforming something (e.g. dog Rex) into a series of 1s and 0s which can be transported over the phone line, ...
Read more >
Bug - (De)serialization not working well with Unity.Physics
When using SerializeUtility.SerializeWorld: System.ArgumentException: Blittable component type 'Unity.Physics.
Read more >
Dropping Java serialization feature
I'm thinking about serialization of java objects in http sessions and the need to send data over the wire for remotely distributed applications; ......
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