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

This commit is contained in:
Nick Fisher committed 2025-06-04 11:07:21 +08:00
1 parent 655ba89b0f
commit c484eeb37f
2 files changed
+13

No files matched your search

@@ -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();