Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for dependencies to load #232

Merged
merged 5 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading