bevyengine / bevyengine/bevy

Crash using AssetServer::watch_for_changes()

Open
#7,008 1 comment 0 reactions 0 assignees View on GitHub
A-Assets C-Bug I-Crash O-Windows
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version
0.8.1 (0.9.1 seems to have the same problems)

## Relevant system information

Windows 10. The problem doesn't appear to happen on Ubuntu systems.

## What you did

Modify an asset located outside the assets folder while being watched for changes by `AssetServer::watch_for_changes()`.

## What went wrong

The program crashes with the following error:

```
thread 'Compute Task Pool (0)' panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())', C:\Users\x\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_asset-0.8.1\src\io\file_asset_io.rs:191:84
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'task has failed', C:\Users\x\.cargo\registry\src\github.com-1ecc6299db9ec823\async-task-4.3.0\src\task.rs:426:43
```

## Additional information

It seems to be crashing after trying to strip a prefix containing the assets folder when the asset itself is not in the assets folder (thus failing to strip the prefix)

`file_asset_io.rs`
```
for path in &paths {
if !changed.contains(path) {
let relative_path = path.strip_prefix(&asset_io.root_path).unwrap();
let _ = asset_server.load_untracked(relative_path.into(), true);
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.