The behavior you're experiencing is related to how Spine.from() creates and caches internal composite assets that combine skeleton data and atlas information.
What's happening:
When you call Spine.from(), it internally creates a cached entry using a composite key (like 'logoSkeleton-logoAtlas-1'). This cached entry combines the skeleton data and atlas into a format optimized for creating Spine instances. However, Assets.unloadBundle() only removes the original assets that were explicitly part of the bundle ('logoSkeleton' and 'logoAtlas'), not the derivative cached entries created by Spine.from().
Solution:
To properly clean up all Spine-related assets, you need to manually remove the composite cache entries before or after unloading the bundle:
// Before unloading the bundle, remove Spine's composite cache entry
Cache.remove('logoSkeleton-logoAtlas-1');
// Then unload the bundle
await Assets.unloadBundle('preloader');
Better approach for dynamic asset management:
If you're frequently loading and unloading bundles with Spine assets, consider tracking the composite keys that Spine.from() creates:
const spineInstances = new Map();
// When creating a Spine instance
const compositeKey = 'logoSkeleton-logoAtlas-1';
const spine = Spine.from({
skeleton: 'logoSkeleton',
atlas: 'logoAtlas'
});
spineInstances.set('logo', compositeKey);
// When cleaning up
const compositeKey = spineInstances.get('logo');
if (compositeKey && Cache.has(compositeKey)) {
Cache.remove(compositeKey);
}
spineInstances.delete('logo');
await Assets.unloadBundle('preloader');
Alternative: Direct asset loading without bundle
If you need more control over asset lifecycle, you could load assets individually rather than using bundles:
// Load
Assets.add({ alias: 'logoSkeleton', src: 'path/to/skeleton.skel' });
Assets.add({ alias: 'logoAtlas', src: 'path/to/skeleton.atlas' });
await Assets.load(['logoSkeleton', 'logoAtlas']);
// Create Spine
const spine = Spine.from({
skeleton: 'logoSkeleton',
atlas: 'logoAtlas'
});
// Clean up
Cache.remove('logoSkeleton-logoAtlas-1');
Assets.unload(['logoSkeleton', 'logoAtlas']);
This behavior is a consequence of how the caching system works with composite assets. The manual cache removal is necessary for complete cleanup when you're managing asset lifecycles dynamically.