bevyengine / bevyengine/bevy

.await for dependecies in AssetServer

Open
#5,297 0 comments 6 reactions 0 assignees View on GitHub
A-Assets C-Bug
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

Currently in bevy `0.7` the asset server **does not** wait for dependencies of some asset to load as can be seen in [the code of `load_untracked` method](https://docs.rs/bevy_asset/latest/src/bevy_asset/asset_server.rs.html#363-369), which is what eventually gets called by the `load` method and alike.

This leads to asset server reporting that the asset is loaded and ready-to-use, while the dependencies of said asset aren't done loading. Which is already somewhat counter-intuitive...

Moreover, it leads to some problems with a very useful crate – [`bevy_asset_loader`](https://github.com/NiklasEi/bevy_asset_loader). The app will transition out of the loading state while, technically speaking, not all needed assets are loaded, leading to a potential crash as described in NiklasEi/bevy_asset_loader#63.

## What solution would you like?

Have `load_untracked` wait for dependencies to load. E.G. have `load_untracked` method `.await` the result of recursive calls `load_untracked` done for the dependencies.

## What alternative(s) have you considered?

`bevy_asset_loader`'s issue could be fixed by giving access to the dependencies of asset (its metadata essentially).

Contributor guide

Open the contributing guide

Research direction

Start with the linked load_untracked implementation in asset_server.rs and trace how load calls it for assets with dependencies. Check how recursive dependency loading currently reports readiness and how bevy_asset_loader relies on that state. Done means load_untracked does not report the asset ready until its dependencies are loaded, without breaking existing asset loading behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.