Skip to content

Commit

Permalink
Merge pull request #232 from NiklasEi/wait_for_dependencies
Browse files Browse the repository at this point in the history
Wait for dependencies to load
  • Loading branch information
NiklasEi authored Jul 13, 2024
2 parents 09f0e1e + 7d45fe4 commit 84170b6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .github/actions/prepare/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: 'Prepare'
description: 'Prepare action runner'
inputs:
cache-key:
description: key for the cache
required: true
runs:
using: "composite"
steps:
Expand All @@ -15,7 +19,7 @@ runs:
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }}
key: ${{inputs.cache-key}}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare/
with:
cache-key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }}
- name: Build & run tests
run: cargo test -p bevy_asset_loader
- name: Build & run tests for derive package
run: cargo test -p bevy_asset_loader_derive
test-2d-3d-dynamic:
dynamic-2d-3d-test:
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare/
with:
cache-key: ${{ runner.os }}-cargo-dynamic-2d-3d-test-${{ hashFiles('**/Cargo.toml') }}
- name: Build & run tests for 2d, 3d, standard
run: cargo test --features "2d, 3d, standard_dynamic_assets" -p bevy_asset_loader
- name: Build & run tests for derive package
Expand All @@ -37,6 +41,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare/
with:
cache-key: ${{ runner.os }}-cargo-progress-tracking-test-${{ hashFiles('**/Cargo.toml') }}
- name: Build & run tests progress tracking
run: cargo test --features "progress_tracking" -p bevy_asset_loader
full-test:
Expand All @@ -47,12 +53,16 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/prepare/
with:
cache-key: ${{ runner.os }}-cargo-full-test-${{ hashFiles('**/Cargo.toml') }}
- name: Build & run tests progress tracking and 2d,3d,dynamic
run: cargo test --features "2d, 3d, standard_dynamic_assets, progress_tracking" -p bevy_asset_loader
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
cache-key: ubuntu-cargo-lint-${{ hashFiles('**/Cargo.toml') }}
- uses: ./.github/actions/prepare/
- uses: taiki-e/install-action@v2
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- custom `on_unimplemented` diagnostics for the `AssetCollection` trait
- image derive attribute `array_texture_layers`
- wait for dependencies of assets to load

## v0.21.0 - 05.07.2024
- support for Bevy 0.14
Expand Down
9 changes: 4 additions & 5 deletions bevy_asset_loader/src/loading_state/systems.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::asset::{AssetServer, LoadState};
use bevy::asset::{AssetServer, RecursiveDependencyLoadState};
use bevy::ecs::system::SystemState;
use bevy::ecs::world::{FromWorld, World};
use bevy::log::{debug, info, trace, warn};
Expand Down Expand Up @@ -107,15 +107,14 @@ fn count_loaded_handles<S: FreelyMutableState, Assets: AssetCollection>(

let failure = loading_asset_handles.handles.iter().any(|handle| {
matches!(
asset_server.get_load_state(handle.id()),
Some(LoadState::Failed(_))
asset_server.get_recursive_dependency_load_state(handle.id()),
Some(RecursiveDependencyLoadState::Failed)
)
});
let done = loading_asset_handles
.handles
.iter()
.map(|handle| asset_server.get_load_state(handle.id()))
.filter(|state| state == &Some(LoadState::Loaded))
.filter(|handle| asset_server.is_loaded_with_dependencies(handle.id()))
.count();
if done < total && !failure {
return (done as u32, total as u32);
Expand Down

0 comments on commit 84170b6

Please sign in to comment.