Skip to content

Commit

Permalink
Fix potential deadlock in AssetServer on single-threaded modes. (#1…
Browse files Browse the repository at this point in the history
…5808)

# Objective

Fixes #15807 

## Solution

We move the guard into this function.

## Testing

N/A, This is just reverting to the old behavior before #15509.
  • Loading branch information
andriyDev authored Oct 11, 2024
1 parent cdd71af commit 60a9a81
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 60a9a81

Please sign in to comment.