mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
drop info locks in single threaded (#15522)
# Objective addresses half of issue #15508 avoid asset server deadlock when `multi_threaded` feature is not enabled. ## Solution drop the locks in the single-threaded case. the lock is still held with the `multi-threaded` feature enabled to avoid re-locking to insert the load task. i guess this might possibly cause issues on single-core machines ... is that something we should worry about? --------- Co-authored-by: Christian Hughes <9044780+ItsDoot@users.noreply.github.com> Co-authored-by: james7132 <contact@jamessliu.com> Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com> Co-authored-by: Emerson Coskey <56370779+ecoskey@users.noreply.github.com> Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Tim <JustTheCoolDude@gmail.com> Co-authored-by: Joona Aalto <jondolf.dev@gmail.com> Co-authored-by: s-puig <39652109+s-puig@users.noreply.github.com> Co-authored-by: Carter Anderson <mcanders1@gmail.com> Co-authored-by: Liam Gallagher <liam@liamgallagher.dev> Co-authored-by: Matty <weatherleymatthew@gmail.com> Co-authored-by: Zachary Harrold <zac@harrold.com.au> Co-authored-by: Benjamin Brienen <benjamin.brienen@outlook.com> Co-authored-by: charlotte <charlotte.c.mcelwain@gmail.com> Co-authored-by: akimakinai <105044389+akimakinai@users.noreply.github.com> Co-authored-by: Antony <antony.m.3012@gmail.com> Co-authored-by: JohnTheCoolingFan <43478602+JohnTheCoolingFan@users.noreply.github.com> Co-authored-by: hshrimp <182684536+hooded-shrimp@users.noreply.github.com> Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com> Co-authored-by: Dokkae <90514461+Dokkae6949@users.noreply.github.com> Co-authored-by: François Mockers <mockersf@gmail.com> Co-authored-by: MiniaczQ <xnetroidpl@gmail.com> Co-authored-by: Pablo Reinhardt <126117294+pablo-lua@users.noreply.github.com> Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com> Co-authored-by: Sou1gh0st <xiuyutong1994@163.com> Co-authored-by: Robert Walter <26892280+RobWalt@users.noreply.github.com> Co-authored-by: eckz <567737+eckz@users.noreply.github.com> Co-authored-by: Matty <2975848+mweatherley@users.noreply.github.com> Co-authored-by: IQuick 143 <IQuick143cz@gmail.com> Co-authored-by: Giacomo Stevanato <giaco.stevanato@gmail.com> Co-authored-by: Clar Fon <15850505+clarfonthey@users.noreply.github.com> Co-authored-by: andriyDev <andriydzikh@gmail.com> Co-authored-by: TheBigCheese <32036861+13ros27@users.noreply.github.com> Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com> Co-authored-by: IceSentry <IceSentry@users.noreply.github.com> Co-authored-by: Josh Robson Chase <josh@robsonchase.com> Co-authored-by: Erik Živković <erik@zivkovic.se> Co-authored-by: ChosenName <69129796+ChosenName@users.noreply.github.com> Co-authored-by: mgi388 <135186256+mgi388@users.noreply.github.com> Co-authored-by: SpecificProtagonist <specificprotagonist@posteo.org> Co-authored-by: ickshonpe <david.curthoys@googlemail.com> Co-authored-by: Gabriel Bourgeois <gabriel.bourgeoisv4si@gmail.com> Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com> Co-authored-by: Trashtalk217 <trashtalk217@gmail.com> Co-authored-by: re0312 <re0312@outlook.com> Co-authored-by: re0312 <45868716+re0312@users.noreply.github.com> Co-authored-by: Periwink <charlesbour@gmail.com> Co-authored-by: Anselmo Sampietro <ans.samp@gmail.com> Co-authored-by: rudderbucky <anandkwork7@gmail.com> Co-authored-by: aecsocket <43144841+aecsocket@users.noreply.github.com> Co-authored-by: Andreas <34456840+nilsiker@users.noreply.github.com> Co-authored-by: Ludwig DUBOS <ludwig.dubos@pm.me> Co-authored-by: Ensar Sarajčić <dev@ensarsarajcic.com> Co-authored-by: Kanabenki <lucien.menassol@gmail.com> Co-authored-by: François Mockers <francois.mockers@vleue.com> Co-authored-by: m-edlund <me@fwegmann.com> Co-authored-by: vero <rodol@rivalrebels.com> Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com> Co-authored-by: Litttle_fish <38809254+Litttlefish@users.noreply.github.com> Co-authored-by: BD103 <59022059+BD103@users.noreply.github.com> Co-authored-by: Rich Churcher <rich.churcher@gmail.com> Co-authored-by: Viktor Gustavsson <villor94@gmail.com> Co-authored-by: Dragoș Tiselice <dragostiselice@gmail.com> Co-authored-by: Miles Silberling-Cook <NthTensor@users.noreply.github.com> Co-authored-by: notmd <33456881+notmd@users.noreply.github.com> Co-authored-by: Matt Tracy <matt.r.tracy@gmail.com> Co-authored-by: Patrick Walton <pcwalton@mimiga.net> Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net> Co-authored-by: rewin <rewin1996@gmail.com> Co-authored-by: a.yamaev <a.yamaev@smartengines.com> Co-authored-by: fluffiac <f@ggot.wtf>
This commit is contained in:
parent
2530f262f5
commit
e72b9625d7
1 changed files with 14 additions and 0 deletions
|
@ -420,6 +420,10 @@ impl AssetServer {
|
|||
infos: &mut AssetInfos,
|
||||
guard: G,
|
||||
) {
|
||||
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded
|
||||
#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))]
|
||||
drop(infos);
|
||||
|
||||
let owned_handle = handle.clone();
|
||||
let server = self.clone();
|
||||
let task = IoTaskPool::get().spawn(async move {
|
||||
|
@ -469,6 +473,11 @@ impl AssetServer {
|
|||
HandleLoadingMode::Request,
|
||||
meta_transform,
|
||||
);
|
||||
|
||||
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded
|
||||
#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))]
|
||||
drop(infos);
|
||||
|
||||
if !should_load {
|
||||
return handle;
|
||||
}
|
||||
|
@ -778,6 +787,11 @@ impl AssetServer {
|
|||
let mut infos = self.data.infos.write();
|
||||
let handle =
|
||||
infos.create_loading_handle_untyped(TypeId::of::<A>(), core::any::type_name::<A>());
|
||||
|
||||
// drop the lock on `AssetInfos` before spawning a task that may block on it in single-threaded
|
||||
#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))]
|
||||
drop(infos);
|
||||
|
||||
let id = handle.id();
|
||||
|
||||
let event_sender = self.data.asset_event_sender.clone();
|
||||
|
|
Loading…
Reference in a new issue