Skip to content

Align bevy_transform's feature flags#23919

Merged
alice-i-cecile merged 4 commits intobevyengine:mainfrom
Sieluna:transform-feature
Apr 22, 2026
Merged

Align bevy_transform's feature flags#23919
alice-i-cecile merged 4 commits intobevyengine:mainfrom
Sieluna:transform-feature

Conversation

@Sieluna
Copy link
Copy Markdown
Contributor

@Sieluna Sieluna commented Apr 21, 2026

Objective

bevy_transform's multi-threading behavior was previously gated on feature = "std", which incorrectly conflated standard library availability with multi-threading capability. This means:

  • Users who enabled no_std but had multi-threading available lost parallelism unintentionally.
  • Users who had std but wanted single-threaded execution (e.g. WASM) still attempted to use the parallel path.
  • bevy_internal's multi_threaded feature did not propagate down to bevy_transform, so the parallel implementation was not activated when expected.
  • The bevy_log dependency was pulled in unconditionally via the std feature, when the only use was optional trace-level warnings.

Solution

  • Added an explicit multi_threaded feature to bevy_transform, backed by bevy_tasks/multi_threaded, matching the pattern used by bevy_ecs and other crates.
  • Replaced all #[cfg(feature = "std")] / #[cfg(not(feature = "std"))] guards on parallel/serial code paths with #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] / #[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))] — the same guard pattern already used in bevy_ecs.
  • Added bevy_transform/multi_threaded to bevy_internal's and bevy_render's multi_threaded feature lists so parallel transforms are activated end-to-end when building Bevy with multi_threaded.
  • Removed the bevy_log dependency from bevy_transform. Its sole usage was a warn_once! inside propagate_transforms_for. This is replaced with a direct tracing::warn! wrapped in bevy_utils::once!, gated on a new opt-in trace feature (dep:tracing). This keeps the default build lighter.
  • Inlined the trace feature spans in mark_dirty_trees that previously depended on bevy_log's re-exported tracing, now using tracing directly under #[cfg(feature = "trace")].

Testing

  • All existing unit tests in bevy_transform::systems::test pass unchanged — no behavioral changes, only cfg guard corrections.
  • No performance regressions observed by Benchmark.

@Sieluna Sieluna force-pushed the transform-feature branch from 633274e to 2125100 Compare April 21, 2026 12:43
@alice-i-cecile alice-i-cecile requested a review from aevyrie April 21, 2026 16:44
@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Transform Translations, rotations and scales M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Uncontroversial This work is generally agreed upon S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 21, 2026
@alice-i-cecile alice-i-cecile self-requested a review April 21, 2026 16:44
@github-actions
Copy link
Copy Markdown
Contributor

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

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

# bevy
bevy_app = { path = "../bevy_app", version = "0.19.0-dev", default-features = false, optional = true }
bevy_ecs = { path = "../bevy_ecs", version = "0.19.0-dev", default-features = false, optional = true }
bevy_log = { path = "../bevy_log", version = "0.19.0-dev", default-features = false, optional = true }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you say more about why it was helpful to remove this dependency in this PR? Does it not have no_std support?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The trace feature in bevy_transform is intentionally aligned with bevy_ecs, since bevy_transform is a sub-crate that should follow the parent crate's conventions:

trace = ["std", "dep:tracing"]

tracing = { version = "0.1", default-features = false, optional = true }

bevy_transform uses exactly the same pattern. The feature name, dependency declaration, and enable condition are identical.

bevy_log is a user-facing subscriber configuration crate — pulling it in for a single tracing::warn! adds unnecessary weight to a mid-graph crate that should stay minimal.

Copy link
Copy Markdown
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Very clean, but needs a migration guide. Feature flags are a pain to try and diagnose during upgrades.

I'd also like a better understanding of the bevy_log situation.

@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-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 21, 2026
@Sieluna

This comment was marked as off-topic.

@alice-i-cecile
Copy link
Copy Markdown
Member

I don't think performance concerns are very relevant here. Did you see the comment from the bot above about the migration guide? We need to explain how users can migrate their feature flag setup.

Comment thread _release-content/migration-guides/align_transform_feature_flags.md
@alice-i-cecile alice-i-cecile 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 Apr 21, 2026
@alice-i-cecile alice-i-cecile requested a review from kfc35 April 21, 2026 23:59
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 left a comment

Choose a reason for hiding this comment

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

logic looks good

Comment thread _release-content/migration-guides/align_transform_feature_flags.md Outdated
Comment thread _release-content/migration-guides/align_transform_feature_flags.md Outdated
Comment thread _release-content/migration-guides/align_transform_feature_flags.md Outdated
Comment thread _release-content/migration-guides/align_transform_feature_flags.md Outdated
@kfc35 kfc35 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 Apr 22, 2026
Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 22, 2026
Merged via the queue into bevyengine:main with commit c7f2038 Apr 22, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Transform Translations, rotations and scales C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants