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

Add backwards compatibility to former (incorrect) Name reflect serialization #11485

Closed
wants to merge 2 commits into from

Conversation

coreh
Copy link
Contributor

@coreh coreh commented Jan 23, 2024

Objective

@MrGVSV pointed out that #11447 inadvertently caused a breaking change, since existing scenes might have been serialized with the broken { "name": _, "hash": _ } format for the Name component. This PR aims to avoids that breakage.

Solution

This PR introduces support for deserializing Name either from a string or from a { "name": _, "hash": _ } map. Once enough time has passed and people have re-exported/fixed their files, we can remove this. Added a warning to make sure people are aware of the change.


Changelog

  • Added backwards compatibility support for the former (incorrect) reflect serialization format for the Name component. This will be removed in a future release, so make sure to update any files that might be using the old format.

@coreh coreh changed the title Add backwards compatibility to former Name reflect serialization Add backwards compatibility to former (incorrect) Name reflect serialization Jan 23, 2024
@coreh coreh force-pushed the backwards-compat-name-serde branch from fc533b3 to 8038207 Compare January 23, 2024 02:37
@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Scenes Serialized ECS data stored on the disk labels Jan 23, 2024
/// We've since fixed this on [#11447](https://github.com/bevyengine/bevy/pull/11447), but in order
/// to maintain backwards compatibility with data that might have been serialized with the wrong format,
/// we should keep support for deserializing it for a bit. (A couple of releases should be enough.)
fn visit_map<A>(self, mut map: A) -> Result<Self::Value, A::Error>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we mark trait methods as deprecated?

If not, can we call a function that's marked deprecated so we can CTRL+F to find it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No 😕 I tried it but the compiler complained about that.

Let me try this calling other function hack.

Copy link
Contributor Author

@coreh coreh Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, actually calling it was causing us to emit a warning on every build, which isn't nice. I just left it around (starting with a _ to prevent dead code warnings) for searchability.

@coreh coreh force-pushed the backwards-compat-name-serde branch from 208f0a0 to 4158533 Compare January 23, 2024 03:04
Comment on lines -21 to +24
deserializer.deserialize_str(EntityVisitor)
deserializer.deserialize_any(EntityVisitor)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could be wrong but I believe this is also a breaking change. IIRC non-self-describing formats do not support deserialize_any.

Could you verify that this doesn't break non-self-describing formats?

@coreh
Copy link
Contributor Author

coreh commented Jan 24, 2024

After discussing with @MrGVSV, this might be overkill, and breaks compatibility with non-self-describing formats. (such as Postcard) I'm going to close this PR and just add a migration guide to the other PR.

If there's demand for it, I can re-open it under a feature flag (e.g. serialize_backwards_compat) so that it's opt-in. Such a flag might be useful to do serialization migrations in the future, but since we're 0.x it's possibly still too early for that.

@coreh coreh closed this Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Scenes Serialized ECS data stored on the disk C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants