Skip to content

Stop automatically generating meta files for assets while using asset processing.#17216

Merged
cart merged 9 commits intobevyengine:mainfrom
andriyDev:no-meta
Mar 6, 2025
Merged

Stop automatically generating meta files for assets while using asset processing.#17216
cart merged 9 commits intobevyengine:mainfrom
andriyDev:no-meta

Conversation

@andriyDev
Copy link
Contributor

@andriyDev andriyDev commented Jan 7, 2025

Objective

  • Today, enabling asset processing can generate many meta files. This makes it a painful transition for users as they get a "mega commit" containing tons of meta files.

Solution

  • Stop automatically generating meta files! Users can just leave the meta files defaulted.
  • Add a function AssetServer::write_default_meta_file_for_path

Testing

  • Tested this manually on the asset_processing example (by removing the meta files for the assets that had default meta files).
  • I did not add a unit test for the write_default_meta_file_for_path since we don't have an in-memory asset writer. Writing one could be useful in the future.

Showcase

Asset processing no longer automatically generates meta files! This makes it much easier to transition to using asset processing since you don't suddenly get many meta files when turning it on.

You can still manually generate meta files using the new AssetServer::write_default_meta_file_for_path function.

@IQuick143 IQuick143 added A-Assets Load files from disk to use for things like images, models, and sounds M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2025

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Could you add some context on what users should update when this change get released in a new version of Bevy?
It will be used to help writing the migration guide for the version. Putting it after a ## Migration Guide will help it get automatically picked up by our tooling.

@andriyDev
Copy link
Contributor Author

I don't think this PR needs a migration guide since users don't need to change any existing stuff for their assets to work. New assets will also continue to work, though new meta files will have to be created using the provided function or manually created.

@BenjaminBrienen BenjaminBrienen removed the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jan 7, 2025
@alice-i-cecile alice-i-cecile requested a review from viridia January 7, 2025 18:45
@alice-i-cecile alice-i-cecile added the C-Bug An unexpected or incorrect behavior label Jan 7, 2025
Copy link
Contributor

@viridia viridia left a comment

Choose a reason for hiding this comment

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

Looks fine to me. Do we want to wait for cart to weigh in on this?

@viridia
Copy link
Contributor

viridia commented Jan 7, 2025

In terms of guides, I can write up something once all changes are in and the dust has settled. Not a migration guide so much as a description of the new workflow.

@BenjaminBrienen BenjaminBrienen added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 11, 2025
@BenjaminBrienen
Copy link
Contributor

BenjaminBrienen commented Jan 11, 2025

Copy link
Member

@mockersf mockersf left a comment

Choose a reason for hiding this comment

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

to keep the same behaviour, I would prefer if the new function didn't overwrite files

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Jan 14, 2025
@andriyDev
Copy link
Contributor Author

I went with returning an error if the meta file already exists (as opposed to silently succeeding). Unfortunately this required me to try to read the meta file just to check if it's there, but that doesn't seem too bad.

@andriyDev andriyDev requested a review from mockersf January 15, 2025 02:25
@mockersf mockersf dismissed their stale review January 15, 2025 22:29

previous review no longer applicable, will re-review... when I can

@andriyDev andriyDev added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Mar 2, 2025
@andriyDev andriyDev added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 2, 2025
@alice-i-cecile alice-i-cecile added this to the 0.16 milestone Mar 2, 2025
@andriyDev andriyDev requested a review from cart March 4, 2025 02:33
@alice-i-cecile alice-i-cecile added M-Release-Note Work that should be called out in the blog due to impact C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed C-Bug An unexpected or incorrect behavior S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Mar 4, 2025
@alice-i-cecile
Copy link
Member

Waiting for @cart's re-review before merging, but if that's not forthcoming I intend to merge this before we cut the 0.16 release candidate :)

@cart cart added this pull request to the merge queue Mar 6, 2025
Merged via the queue into bevyengine:main with commit d8f3eb3 Mar 6, 2025
33 checks passed
@andriyDev andriyDev deleted the no-meta branch March 6, 2025 21:11
@alice-i-cecile
Copy link
Member

Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#2000 if you'd like to help out.

github-merge-queue bot pushed a commit that referenced this pull request Dec 22, 2025
…t keep the instrumentation. (#22213)

# Objective

- In #12988, we added tracing spans to asset loading and processing, by
creating wrapper structs `InstrumentedAssetLoader` and
`InstrumentedAssetProcessor`.
- Unfortunately, this causes an issue where
`ErasedAssetLoader::{default_meta, type_path}` and
`ErasedProcessor::default_meta` can return the wrong type path when
using the `trace` feature, and this type path could be written into a
meta file, which will be rendered unloadable/unprocessable.
- Note even though the loader/processor's type use to have the
instrumentation wrapper, when registering the loader/processor, we would
actually register the loader/processor under the original type names. So
you could still load non-`trace` written meta files, but `trace` written
meta files would fail to load whether `trace` was enabled or not!

## Solution

- Remove the wrapper loader/processor and instead just create the spans
at the callsites. I checked and there's a single callsite of `load` and
a single callsite of `process` - very good!
- I also added testing that was omitted in #17216 (due to missing test
utilities which have since been added). This is how I found out about
this problem! Score one for testing.

## Testing

- We still produce spans in the `asset_processing` example for both
loading and processing.

Note: We don't need a migration guide since users should really not be
using these directly, and any meta files using these would just be
broken.
github-merge-queue bot pushed a commit that referenced this pull request Feb 22, 2026
…tead of the long type path. (#22208)

# Objective

- Context: In #17216, we stopped automatically generating meta files for
assets, but provided explicit functions for generating meta files.
- In #21339, we allowed asset processors to be specified by their short
type path in meta files.
- However, the meta file generating functions still produced
fully-qualified type paths for processors. So even though we supported
much more readable processor meta files, we didn't take advantage of
that when generating meta files.
- Fulfilling my obligations to cart:
#21339 (comment)

## Solution

- Make `ErasedProcessor` have a method for returning its
`short_type_path`, and make its `default_meta` method take an enum to
choose between using the short or long type path.
- When generating the default meta, first lookup the processor using its
short type name. If it's ambiguous, use the long type path.
- Add tests to show the short/long selection. As part of this, I forced
all meta files to be serialized with `\n` as the new line character.
- Bonus: add more tests for `write_default_meta_file_for_path` and
`write_default_loader_meta_file_for_path` which were omitted in #17216
due to missing appropriate testing utilities (specifically a memory
asset writer).

## Testing

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

Labels

A-Assets Load files from disk to use for things like images, models, and sounds C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants