Skip to content

0.4 -> 0.5 Migration Guide #1601

Closed
Closed

Description

@cart

0.5 will have breaking changes, and some of them will not be intuitive. We should have an official migration guide to help our users upgrade.

Lets use this issue as a way to track the important breaking changes to include. I'll start with:

  1. commands: &mut Commands has changed back to mut commands: Commands. This will cause previously valid foo.system() calls to fail to compile.
  2. The max number of SystemParams has gone from 15 to 12. This is because they now rely on Rust's Default impl for tuples, which only extends to tuples of length 12. Users can use nested tuples and/or SystemParam derives to work around this. Both options help organize parameters, which is a good thing to do anyway for systems with a large number of params.
  3. commands.insert_one(component) is now commands.insert(component). commands.insert(bundle) is now commands.insert_bundle(bundle). This means that 0.4 code that does commands.insert(bundle) will now attempt to insert bundle as a component instead of a bundle, which will cause breakage. This will cause confusion, but this change was made to help make bundles less easy to confuse with components, so I think that it is ultimately the right call.

Activity

  1. added this to the Bevy 0.5 milestone on Mar 9, 2021
  2. added
    C-DocsAn addition or correction to our documentation
    on Mar 9, 2021
  3. alice-i-cecile commented on Mar 9, 2021

    @alice-i-cecile
    Member
    1. Event changes in Make EventReader a SystemParam #1244 and [Merged by Bors] - Add EventWriter #1575.
    2. add_resource changed to insert_resource in Rename add_resource to insert_resource #1356.
    3. System dependencies and ambiguities in System sets and parallel executor v2 #1144.
    4. Timer changes in [Merged by Bors] - ♻️ Timer refactor to duration.✨ Add Stopwatch struct. #1151.
    5. init_resource no longer overwrites in Update init_resource to not overwrite #1349 (no one should have been relying on this, but it may cause hard-to-track down breakages).

    Tentative:
    9. State rework in #1424.
    10. Mutated removed in #1471.
    11. All of the stage overhaul work that is likely to come out of #1466.

  4. alice-i-cecile commented on Mar 9, 2021

    @alice-i-cecile
    Member
    1. ChangedRes removed in [Merged by Bors] - Get rid of ChangedRes #1313.
    2. Stage labels have been changed in Add Label type #1423.
    3. Thread-local resources -> NonSend resources in System sets and parallel executor v2 #1144.
    4. Thread-local systems -> exclusive systems in System sets and parallel executor v2 #1144.
    5. Orthographic projection changes in OrthographicProjection scaling mode + camera bundle refactoring #400.
    6. Box<dyn System> is now BoxedSystem

    Okay, I've reviewed the closed PRs going back to the 0.4 release so I think that's most of the breaking changes, other than :thepr:.

  5. rparrett commented on Mar 9, 2021

    @rparrett
    Contributor
    1. New query conflict stuff
  6. alice-i-cecile commented on Mar 9, 2021

    @alice-i-cecile
    Member

    From #1525:

    1. Resources merged into World.
    2. Several functions and traits are now appropriately unsafe.
    3. Removed Mut<T> in favor of &mut T
    4. New RemovedComponents SystemParam that replaces query.removed::()
    5. New World and Command API changes (assuming Adapt Commands apis for consistency with new World apis #1562 lands as planned)
  7. cart commented on Mar 9, 2021

    @cart
    MemberAuthor

    Thanks yall! If anyone wants to volunteer to write the guide, that would be much appreciated. Otherwise I'll get to it eventually 😄

    Each migration item should have a description of the change (with rationale if you anticipate a negative response), descriptions of breakage symptoms (when that is relevant and non-obvious), and small before/after code snippets where relevant

  8. cart commented on Mar 9, 2021

    @cart
    MemberAuthor

    I think this should probably be a new section of the book that we link to from the 0.5 release blog post

  9. cart commented on Mar 9, 2021

    @cart
    MemberAuthor

    Theres enough items here that we should do this piece by piece (which will also help us distribute the work)

  10. cart commented on Mar 9, 2021

    @cart
    MemberAuthor

    So I'm looking for someone to create the template others can build off of. And people should claim numbered items in this thread before working on them.

  11. alice-i-cecile commented on Mar 9, 2021

    @alice-i-cecile
    Member

    @cart want to create a draft PR for this that we can make pull requests onto? Seems like a good way to collaborate.

  12. cart commented on Mar 9, 2021

    @cart
    MemberAuthor

    Good call! Putting that together now.

  13. bitshifter commented on Mar 9, 2021

    @bitshifter
    Contributor

    There are a few breaking changes in glam 0.13.0 documented here https://github.com/bitshifter/glam-rs/blob/master/CHANGELOG.md. The one people might get caught out by is Mat4::transform_point3(Vec3) no longer performs perspective divide, there's a new Mat4::project_point3(Vec3) method for that, if you need to transform points by a perspective projection matrix.

  14. dmtaub commented on Mar 9, 2021

    @dmtaub

    I can take a stab at 2 & 3 -- will also add a small note about Commands' extra lifetime to 1) -- may not be a super common case but it bit me the other day...

  15. alice-i-cecile commented on Mar 10, 2021

    @alice-i-cecile
    Member
  16. 12 remaining items

  17. lassade commented on Mar 25, 2021

    @lassade
    Contributor

    'Camera' uniform should be renamed to 'CameraViewProj'

  18. Byteron commented on Mar 25, 2021

    @Byteron
    Contributor

    I'm not entirely sure if I'm happy with commands.insert() and commands.insert_bundle().
    IMO if there is multiple things that can be inserted they should be stated explicitly.
    if you have commands.insert_bundle that's cool, but then if you see commands.insert() you gotta ask "insert what?".
    I do understand however that commands.insert_component() is rather verbose, and it's something that will be called a lot.
    That's why I'm unsure.

  19. CleanCut commented on Mar 25, 2021

    @CleanCut
    Member

    I'm not entirely sure if I'm happy with commands.insert() and commands.insert_bundle().

    I am happy with it! I think it fits well. In both cases the unstated subject is component(s). How do you insert a component? .insert(). How do you insert a whole bundle of components? .insert_bundle().

    A few months back I got stuck for an hour before I figured out the old API's unstated subject was "bundle of components" for the short method (while the long method was completely explicit--not great symmetry there). I was trying to add a single component with the method that required a bundle 🤦🏼‍♂️ --it was confusing.

  20. alice-i-cecile commented on Mar 28, 2021

    @alice-i-cecile
    Member

    New example from today: handling migration of WorldQuery generic parameters. Link.

  21. foxzool commented on Mar 31, 2021

    @foxzool
    Contributor

    get_mut -> get_resource_mut
    insert_thread_local -> insert_non_send
    get_thread_local -> get_non_send_resource
    get_thread_local_mut -> get_non_send_resource_mut

  22. SuperSamus commented on Apr 7, 2021

    @SuperSamus
    Contributor

    Pull request #1703 made a breaking change by moving some methods from Commands to EntityCommands.

    There is already a question about it on StackOverflow.

  23. BorisBoutillier commented on Apr 9, 2021

    @BorisBoutillier
    Contributor

    The Commands.spawn method has changed from 0.4 to 0.5 as far as I see.
    Commands.spawn calls should be replaced by Commands.spawn_bundle

  24. rparrett commented on Apr 9, 2021

    @rparrett
    Contributor

    The changes to commands that are not currently covered in the migration guide are documented pretty well here: #1703 (and mentioned speculatively above in "number 22")

    An awesome first contribution to Bevy would be a PR that adds this info (and the many other points not covered) to the migration guide.

  25. added
    D-TrivialNice and easy! A great choice to get started with Bevy
    P-HighThis is particularly urgent, and deserves immediate attention
    on Apr 9, 2021
  26. rparrett commented on Apr 9, 2021

    @rparrett
    Contributor

    Added bevyengine/bevy-website#129 which covers number 12 and somewhat minimally, number 22.

  27. szunami commented on Apr 18, 2021

    @szunami
    Contributor

    I just opened bevyengine/bevy-website#133, very glad to see this kind of content being prioritized!

  28. alice-i-cecile commented on Apr 18, 2021

    @alice-i-cecile
    Member
    1. Note that vsync is turned on by default, which may be limiting performance.
  29. cart commented on May 6, 2021

    @cart
    MemberAuthor

    I think we can safely close this one out :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-DocsAn addition or correction to our documentationD-TrivialNice and easy! A great choice to get started with BevyP-HighThis is particularly urgent, and deserves immediate attention

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions