asset_loader returns no texture handle after instances have been removed
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
bevy = { version = "0.10.0" }
bevy-inspector-egui = "0.18.3"
## \[Optional\] Relevant system information
[package]
version = "0.1.0"
edition = "2021"
[profile.dev.package."*"]
opt-level = 3
[profile.dev]
opt-level = 1
windows version: 21H2
the adapter info that appears when you run Bevy: INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce GTX 1070", vendor: 4318, device: 7041, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "516.94", backend: Vulkan }
## What you did
1) I create an entity e1
2) I load a texture asset t1 attach it to e1
3) I create entity e2
4) I load a another texture asset t2 attach it to e2
5) I make e2 a child of e1
6) I call despawn e2 recursive
-> Now I repeat steps 3,4 & 5 with exact same parameters
## What went wrong
The first time (until step 5 and 6) everything is good, the texture is visible.
The second and all consecutive times the texture does not appear. It is created the exact same way.
When I look at it with the inspectur e-gui I see that there is no handle
## Additional information
I extracted the relevant code snippets, this is not executable. If needed I will provide a minimal example.
```
let textue= asset_server.load("path/file.png");
println!("texture1: {:?}", texture);
let entity = commands
.spawn(SpriteBundle {
texture,
..Default::default()
})
.insert(Name::new("card_marker"))
.id();
commands.entity(parent).add_child(entity);
```
after user clicked somewhere:
```
commands.entity(entity).despawn_recursive();
```
another frames later I create it again:
```
let textue= asset_server.load("path/file.png");
println!("texture2: {:?}", texture);
let entity = commands
.spawn(SpriteBundle {
texture,
..Default::default()
})
.insert(Name::new("card_marker"))
.id();
commands.entity(parent).add_child(entity);
```
The handle appears to be the exact same handle (this is the println output):
texture1: StrongHandle(AssetPathId(AssetPathId(SourcePathId(1485840666025915601), LabelId(6298619649789039366))))
texture2: StrongHandle(AssetPathId(AssetPathId(SourcePathId(1485840666025915601), LabelId(6298619649789039366))))
**Screenshots**
- first time the handle in the egui

- second time the handle in the egui shows an empty handle

**workarounds that you used**
Not exactly a workaround yet: But when I open the inpector e-gui and navigate to the texture handle (first screenshot) and keep it open while I do what triggers steps 6, 3, 4, 5. Then it all works fine, which brings me to my theorie:
**theories about what might be going wrong**
The asset loader unloads it after all references are gone, when I then want to load it again it still has some dead thing in cache or something like that
Contributor guide
Assessment
This issue has not been assessed yet.