when destroying an asset, remove/destroy instances before destroying the parent asset

This commit is contained in:
Nick Fisher
2025-06-04 11:07:19 +08:00
parent 655ba89b0f
commit c484eeb37f
2 changed files with 13 additions and 0 deletions

View File

@@ -263,6 +263,15 @@ class FFIFilamentApp extends FilamentApp<Pointer> {
///
Future destroyAsset(covariant FFIAsset asset) async {
await asset.removeAnimationComponent();
if (!asset.isInstance) {
for (final instance in (await asset.getInstances()).cast<FFIAsset>()) {
await instance.removeAnimationComponent();
await withVoidCallback((requestId, cb) =>
SceneAsset_destroyRenderThread(instance.asset, requestId, cb));
await instance.dispose();
}
}
await withVoidCallback((requestId, cb) =>
SceneAsset_destroyRenderThread(asset.asset, requestId, cb));
await asset.dispose();