Skip to content

0.18: Potential panic when accessing Meshes due to retained render world only assets #22206

@beicause

Description

@beicause

Bevy version and features

main after #21732

What you did

Run mesh_picking example with a RENDER_WORLD-only mesh and try picking it.

What went wrong

It panics and exits. This is a regression because before #21732 mesh_picking would never access render world only meshes.

Additional information

This is a breaking change that requires a migration guide, especially for physics crates that need to iterate over Meshes. They can easily panic by accidentally accessing a render world only mesh.

The migration path is to always use the try_xxx methods instead of the original ones that could panic, but this may this is unintuitive and error-prone.

Personally, I would suggest we revert it and redo it in 0.19 if this isn’t improved in 0.18, given that the side effects of #21732 currently outweigh its benefits. Disclaimer: I'm not aware of Bevy’s release policy or if this will be improved in the RC. I simply noticed the 0.18.rc1 release.

Potential Improvements:

  • Add some kind of filter or methods at the ECS/Assets level: one for accessing assets of all usage types, and another for accessing main world assets while avoiding render world only assets.
  • Remove the panic-prone methods and replace them with a dedicated interface for access. This could also eliminate the need for many of the redundant try_xxx methods, as suggested in Add ExtractableAsset trait for accessing extractable data #22128.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-BugAn unexpected or incorrect behaviorS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions