bevyengine / bevyengine/bevy

`AssetServer` panics when loading folder

Open
#13,946 3 comments 0 reactions 0 assignees View on GitHub
A-Assets C-Bug C-Usability D-Straightforward S-Needs-Design
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version

`0.14.0-rc.3`

## \[Optional\] Relevant system information

`
SystemInfo { os: "Windows 11 Enterprise", kernel: "22631", cpu: "AMD Ryzen 9 5900X 12-Core Processor", core_count: "12", memory: "63.9 GiB" }
`

`
AdapterInfo { name: "NVIDIA GeForce GTX 1080", vendor: 4318, device: 7040, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "555.99", backend: Vulkan }
`

## What you did

I tried loading folder

```rust
let asset_server = world.resource_ref::();
asset_server.load_folder("/");
```

## What went wrong

It panicked and wrote into console:

```
thread 'IO Task Pool (3)' panicked at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_asset-0.14.0-rc.3\src\io\file\file_asset.rs:65:75:
called `Result::unwrap()` on an `Err` value: StripPrefixError(())
```

While app just ran with this panic I don't think is should panic...

It's intended behaviour ?
Maybe write better panic message ??

## Additional information

```
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d/library\std\src\panicking.rs:652
1: core::panicking::panic_fmt
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d/library\core\src\panicking.rs:72
2: core::result::unwrap_failed
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d/library\core\src\result.rs:1654
3: enum2$,std::path::StripPrefixError> >::unwrap
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\core\src\result.rs:1077
4: bevy_asset::io::file::file_asset::impl$0::read_directory::async_fn$0::closure$0::closure$0
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_asset-0.14.0-rc.3\src\io\file\file_asset.rs:65
5: enum2$ >::and_then
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\core\src\option.rs:1412
6: bevy_asset::io::file::file_asset::impl$0::read_directory::async_fn$0::closure$0
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_asset-0.14.0-rc.3\src\io\file\file_asset.rs:57
7: futures_lite::stream::impl$41::poll_next
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-2.3.0\src\stream.rs:2550
8: futures_core::stream::if_alloc::impl$0::poll_next >,core::marker::Send,core::marker::Unpin> >
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-core-0.3.30\src\stream.rs:209
9: futures_lite::stream::StreamExt::poll_next >,core::marker::Send,core::marker::Unpin>,alloc::alloc::Global> >
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-2.3.0\src\stream.rs:673
10: futures_lite::stream::impl$22::poll >,core::marker::Send,core::marker::Unpin>,alloc::alloc::Global> >
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-2.3.0\src\stream.rs:1909
11: bevy_asset::server::impl$0::load_folder_internal::load_folder::async_fn$0
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_asset-0.14.0-rc.3\src\server\mod.rs:803
12: bevy_asset::server::impl$0::load_folder_internal::async_block$0
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_asset-0.14.0-rc.3\src\server\mod.rs:858
13: async_executor::impl$5::spawn_inner::async_block$0,enum2$ >
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-executor-1.12.0\src\lib.rs:249
14: core::future::future::impl$1::poll,enum2$ > >,alloc::alloc::Global> >
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\core\src\future\future.rs:123
15: async_task::raw::impl$3::run::closure$1,enum2$ > >,alloc::alloc::Global> >,tuple$<
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-task-4.7.1\src\raw.rs:550
16: core::ops::function::FnOnce::call_once,enum2$ > >,async_task::raw::impl$3::run::closure_env$1,enum2$,enum2$ > >,core::panic::unwind_safe::AssertUnwindSafe,e
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\std\src\panicking.rs:523
21: std::panic::catch_unwind,enum2$,enum2$ > >,alloc::alloc::Global> >,tuple$<>,async_executo
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-task-4.7.1\src\raw.rs:549
23: async_task::runnable::Runnable >::run >
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-task-4.7.1\src\runnable.rs:781
24: async_executor::impl$13::run::async_fn$0::async_block$0,async_channel::RecvError> >,futures_lite::future::Or,async_channel::RecvError> >,futures_lite::future::Or,async_channel::
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\futures-lite-2.3.0\src\future.rs:449
26: async_executor::impl$13::run::async_fn$0,async_channel::RecvError> >,futures_lite::future::Or,async_cha
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-executor-1.12.0\src\lib.rs:747
27: async_executor::impl$5::run::async_fn$0,async_channel::RecvError> >,futures_lite::future::Or,async_chan
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\async-executor-1.12.0\src\lib.rs:343
28: futures_lite::future::block_on::closure$0,async_channel::RecvError> >,enum2$,async_channel::RecvError> >,futures_lite::future::Or > >::try_with >,futures_lite::future::block_on::closure_env$0 > >::with >,futures_lite::future::block_on::closure_env$0,async_channel::RecvError> >,enum2$,async_channel::RecvError> >,futures_lite::future::Or,async_channel::RecvError> > >
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\std\src\panicking.rs:559
34: bevy_tasks::usages::impl$7::deref
35: std::panicking::try,async_channel::RecvError> >,bevy_tasks::task_pool::impl$2::new_internal::closure$0::closure$0::closure$0::closure_env$0>
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\std\src\panicking.rs:523
36: std::panic::catch_unwind,async_channel::RecvError> > >
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\std\src\panic.rs:149
37: bevy_tasks::task_pool::impl$2::new_internal::closure$0::closure$0::closure$0
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_tasks-0.14.0-rc.3\src\task_pool.rs:170
38: std::thread::local::LocalKey::try_with >
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\std\src\thread\local.rs:286
39: std::thread::local::LocalKey::with >
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\std\src\thread\local.rs:262
40: bevy_tasks::task_pool::impl$2::new_internal::closure$0::closure$0
at C:\Users\Pieresqi\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_tasks-0.14.0-rc.3\src\task_pool.rs:163
41: core::hint::black_box
at /rustc/79734f1db8dbe322192dea32c0f6b80ab14c4c1d\library\core\src\hint.rs:338
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

Contributor guide

Open the contributing guide

Research direction

Start at bevy_asset/io/file/file_asset.rs:65, where the reported StripPrefixError unwrap occurs, then follow AssetServer::load_folder through bevy_asset/server/mod.rs:803 and 858. Reproduce the load_folder("/") case and determine the intended behavior; done should avoid the reported panic or provide a clearer failure for this input.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.