diff --git a/crates/bevy_asset/src/server/info.rs b/crates/bevy_asset/src/server/info.rs index 012e47b76adef..1c8cc9309f8b6 100644 --- a/crates/bevy_asset/src/server/info.rs +++ b/crates/bevy_asset/src/server/info.rs @@ -590,6 +590,11 @@ impl AssetInfos { } pub(crate) fn process_asset_fail(&mut self, failed_id: UntypedAssetId, error: AssetLoadError) { + // Check whether the handle has been dropped since the asset was loaded. + if !self.infos.contains_key(&failed_id) { + return; + } + let (dependants_waiting_on_load, dependants_waiting_on_rec_load) = { let info = self .get_mut(failed_id) diff --git a/crates/bevy_gltf/Cargo.toml b/crates/bevy_gltf/Cargo.toml index 55b2d1793a480..d6493e75adfb4 100644 --- a/crates/bevy_gltf/Cargo.toml +++ b/crates/bevy_gltf/Cargo.toml @@ -58,7 +58,6 @@ base64 = "0.22.0" percent-encoding = "2.1" serde = { version = "1.0", features = ["derive"] } serde_json = "1" -futures = "0.3" smallvec = "1.11" [lints] diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 7c8cb56931081..ebbad21f499dc 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -38,10 +38,10 @@ use bevy_render::{ }; use bevy_scene::Scene; #[cfg(not(target_arch = "wasm32"))] +use bevy_tasks::IoTaskPool; use bevy_transform::components::Transform; use bevy_utils::tracing::{error, info_span, warn}; use bevy_utils::{HashMap, HashSet}; -use futures::future::join_all; use gltf::image::Source; use gltf::{ accessor::Iter, @@ -389,22 +389,25 @@ async fn load_gltf<'a, 'b, 'c>( } } else { #[cfg(not(target_arch = "wasm32"))] - let futures = gltf.textures().map(|gltf_texture| { - let parent_path = load_context.path().parent().unwrap(); - let linear_textures = &linear_textures; - let buffer_data = &buffer_data; - load_image( - gltf_texture, - buffer_data, - linear_textures, - parent_path, - loader.supported_compressed_formats, - settings.load_materials, - ) - }); - - join_all(futures) - .await + IoTaskPool::get() + .scope(|scope| { + gltf.textures().for_each(|gltf_texture| { + let parent_path = load_context.path().parent().unwrap(); + let linear_textures = &linear_textures; + let buffer_data = &buffer_data; + scope.spawn(async move { + load_image( + gltf_texture, + buffer_data, + linear_textures, + parent_path, + loader.supported_compressed_formats, + settings.load_materials, + ) + .await + }); + }); + }) .into_iter() .for_each(|result| match result { Ok(image) => {