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

Fix potential deadlock in AssetServer on single-threaded modes. #15808

Merged
merged 1 commit into from
Oct 11, 2024
Merged
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
8 changes: 4 additions & 4 deletions crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use either::Either;
use futures_lite::{FutureExt, StreamExt};
use info::*;
use loaders::*;
use parking_lot::RwLock;
use parking_lot::{RwLock, RwLockWriteGuard};
use std::path::{Path, PathBuf};

/// Loads and tracks the state of [`Asset`] values from a configured [`AssetReader`](crate::io::AssetReader). This can be used to kick off new asset loads and
Expand Down Expand Up @@ -383,7 +383,7 @@ impl AssetServer {
);

if should_load {
self.spawn_load_task(handle.clone().untyped(), path, &mut infos, guard);
self.spawn_load_task(handle.clone().untyped(), path, infos, guard);
}

handle
Expand All @@ -407,7 +407,7 @@ impl AssetServer {
);

if should_load {
self.spawn_load_task(handle.clone(), path, &mut infos, guard);
self.spawn_load_task(handle.clone(), path, infos, guard);
}

handle
Expand All @@ -417,7 +417,7 @@ impl AssetServer {
&self,
handle: UntypedHandle,
path: AssetPath<'static>,
infos: &mut AssetInfos,
mut infos: RwLockWriteGuard<AssetInfos>,
guard: G,
) {
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded
Expand Down