Skip to content

Don't trigger change detections inAssets<A>::track_assets if not necessary#23752

Merged
alice-i-cecile merged 1 commit intobevyengine:mainfrom
loreball:stop_assets_always_changed
Apr 12, 2026
Merged

Don't trigger change detections inAssets<A>::track_assets if not necessary#23752
alice-i-cecile merged 1 commit intobevyengine:mainfrom
loreball:stop_assets_always_changed

Conversation

@loreball
Copy link
Copy Markdown
Contributor

Objective

Fix #23626

Solution

Don't mutably dereference assets when not needed

Testing

Tried to write a integration test but couldn't get it to work with MinimalPlugins. Tested manually

Methodology

Ran

//! asd
use bevy::prelude::*;

/// asd
fn main() -> AppExit {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Update, test)
        .run()
}

/// asd
fn test(assets: Res<Assets<Mesh>>) {
    if assets.is_changed() {
        info!("{}", assets.changed_by());
    }
}

observed (note we're not getting spammed each frame):

2026-04-10T18:36:47.589526Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: ...
2026-04-10T18:36:47.623739Z  INFO bevy_render::renderer: ...
2026-04-10T18:36:48.048787Z  INFO bevy_pbr::cluster: GPU clustering is supported on this device.
2026-04-10T18:36:48.048922Z  INFO bevy_render::batching::gpu_preprocessing: GPU preprocessing is fully supported on this device.
2026-04-10T18:36:48.051537Z  INFO bevy_winit::system: Creating new window bevy (65v0)
2026-04-10T18:36:48.064398Z  INFO bevy: crates/bevy_sprite_render/src/sprite_mesh/mod.rs:42:22
2026-04-10T18:36:48.169366Z  INFO bevy: crates/bevy_asset/src/assets.rs:613:30
2026-04-10T18:36:57.181161Z  INFO bevy_window::system: No windows are open, exiting
2026-04-10T18:36:57.182245Z  INFO bevy_winit::system: Closing window 65v0

@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it C-Bug An unexpected or incorrect behavior A-Assets Load files from disk to use for things like images, models, and sounds labels Apr 10, 2026
@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Apr 10, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Assets Apr 10, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Apr 12, 2026
Merged via the queue into bevyengine:main with commit ec96800 Apr 12, 2026
47 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in Assets Apr 12, 2026
@loreball loreball deleted the stop_assets_always_changed branch April 12, 2026 21:30
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-Bug An unexpected or incorrect behavior D-Trivial Nice and easy! A great choice to get started with Bevy S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Res<Assets<T>>.is_changed() always true

3 participants