#Gltf Asset unloaded despite strongHandle

9 messages ยท Page 1 of 1 (latest)

void coyote
#

Hi folks, I am really stuck, and might be missing something obvious: I keep having gltf files unloaded right after they finished loading,

  • my Gltf handle inside a resource is a strong handle
  • and from what I read a handle does not get dropped as long as at least a single strong handle still exists ?
  • from the console debugging I can see the gltf load state going loading => loaded => unloaded
  • stranger still, the AssetEvent::Created seems to fire after the asset is unloaded ??

Any ideas would be very welcome, thanks ! ๐Ÿ™‚

I created a minimal error reproduction (see below);

 
fn main() {
    App::new()
        .add_plugins((
            DefaultPlugins.set(AssetPlugin {
                ..default()
            }),
        ))
        .add_systems(Startup, setup)
        .add_systems(Update, track_creation)
        .add_systems(Update, track_loadstate)
        .run();
}


#[derive(Resource)]
pub struct MyGltf ( pub Handle<Gltf> );

fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    commands.insert_resource(MyGltf(asset_server.load("animation/models/World.glb#Scene0")));
}

fn track_creation(
    mut events: EventReader<AssetEvent<Gltf>>,
) {
    for event in events.iter() {
        if let AssetEvent::Created { handle } = event {
            info!("gltf created {:?}", handle.clone());
        }
    }
}

fn track_loadstate(
    asset_server: Res<AssetServer>,
    bla: ResMut<MyGltf>
){
    info!(
        "checking for loaded gltfs {:?}",
        asset_server.get_load_state(&bla.0)
    );
}```
jade chasm
#

Just skimming over the source, maybe you should have a Handle<Scene> and not a Handle<Gltf>? but not sure

void coyote
#

Thanks for the tip, but I actually need to have Gltf file handles ๐Ÿ™‚ And well, they load before ...unloading ๐Ÿ˜„

#

After further investigation, it seems the problem is not present for all gltf files, but anything I tried that is larger than 2 Mb gets unloaded

jade chasm
#

Your repro gives me the following output with a 21MB glb:

2023-10-24T09:19:16.864316Z  INFO bevy_gltf_unload: checking for loaded gltfs Loading
2023-10-24T09:19:16.866583Z  INFO bevy_gltf_unload: checking for loaded gltfs Loaded
2023-10-24T09:19:16.879888Z  INFO bevy_gltf_unload: checking for loaded gltfs Loaded
2023-10-24T09:19:16.879890Z  INFO bevy_gltf_unload: gltf created WeakHandle<Gltf>(AssetPathId(AssetPathId(SourcePathId(17557575683770202922), LabelId(8823233378563626002))))
2023-10-24T09:19:16.960354Z  INFO bevy_gltf_unload: checking for loaded gltfs Loaded
2023-10-24T09:19:16.964236Z  INFO bevy_gltf_unload: checking for loaded gltfs Loaded
2023-10-24T09:19:16.966193Z  INFO bevy_gltf_unload: checking for loaded gltfs Loaded
2023-10-24T09:19:16.967911Z  INFO bevy_gltf_unload: checking for loaded gltfs Loaded
#

and then it stays loaded

#

which version of bevy are you on?

void coyote
void coyote