Jump to content

Spine.from() still works after Assets.unloadBundle — cached data not cleared (Pixi.js 8.17.1 & @esotericsoftware/spine-pixi-v8 4.2.107)


RubenPG
 Share

Recommended Posts

Hello,
I'm running into some unexpected caching behavior with Spine in PixiJS v8.

Package versions:
"pixi.js": "8.17.1"
"@esotericsoftware/spine-pixi-v8": "4.2.107"

Example:
// STEP 1 — Load bundle

await Assets.loadBundle('preloader');

// Assets are now available
console.log([...Cache.keys()]); 
// = ['logoSkeleton', 'logoAtlas']

Assets.cache.has('logoSkeleton'); // = true
Assets.cache.has('logoAtlas');    // = true


// STEP 2 — Create first Spine instance
const spine = Spine.from({
  skeleton: 'logoSkeleton',
  atlas: 'logoAtlas'
});


// Cache AFTER creating Spine 
// record 'logoSkeleton-logoAtlas-1' added by Spine.from()
console.log([...Cache.keys()]); 
// = ['logoSkeleton', 'logoAtlas', 'logoSkeleton-logoAtlas-1']

Assets.cache.has('logoSkeleton') ;              // = true
Assets.cache.has('logoAtlas');                  // = true
Assets.cache.has('logoSkeleton-logoAtlas-1');   // = true


// STEP 3 — Unload bundle
await Assets.unloadBundle('preloader');


// Verify Assets cache is cleared
Assets.cache.has('logoSkeleton');               // = false
Assets.cache.has('logoAtlas');                  // = false
Assets.cache.has('logoSkeleton-logoAtlas-1');   // = true !!!


// Check Cache after unload
console.log([...Cache.keys()]); 
// = ['logoSkeleton-logoAtlas-1']
// ! Unload did not remove 'logoSkeleton-logoAtlas-1' from Cache


// STEP 4 — Create second Spine instance,
// still works because 'logoSkeleton-logoAtlas-1' is in Cache,
// even though original assets were unloaded
spine2 = Spine.from({
  skeleton: 'logoSkeleton',
  atlas: 'logoAtlas'
});

I would expect that unloading a bundle remove all related assets.
Why is this not the case? Do I need to implement a workaround?
I’ve confirmed that this works, but it doesn’t seem maintainable or flexible for a larger codebase:

Cache.remove('logoSkeleton-logoAtlas-1');

 

Link to comment
Share on other sites

On 4/2/2026 at 5:18 PM, RubenPG said:
Hello,
I'm running into some unexpected caching behavior with Spine in PixiJS v8.

Package versions:
"pixi.js": "8.17.1"
"@esotericsoftware/spine-pixi-v8": "4.2.107"

Example:
// STEP 1 — Load bundle

await Assets.loadBundle('preloader');

// Assets are now available
console.log([...Cache.keys()]); 
// = ['logoSkeleton', 'logoAtlas']

Assets.cache.has('logoSkeleton'); // = true
Assets.cache.has('logoAtlas');    // = true


// STEP 2 — Create first Spine instance
const spine = Spine.from({
  skeleton: 'logoSkeleton',
  atlas: 'logoAtlas'
});


// Cache AFTER creating Spine 
// record 'logoSkeleton-logoAtlas-1' added by Spine.from()
console.log([...Cache.keys()]); 
// = ['logoSkeleton', 'logoAtlas', 'logoSkeleton-logoAtlas-1']

Assets.cache.has('logoSkeleton') ;              // = true
Assets.cache.has('logoAtlas');                  // = true
Assets.cache.has('logoSkeleton-logoAtlas-1');   // = true


// STEP 3 — Unload bundle
await Assets.unloadBundle('preloader');


// Verify Assets cache is cleared
Assets.cache.has('logoSkeleton');               // = false
Assets.cache.has('logoAtlas');                  // = false
Assets.cache.has('logoSkeleton-logoAtlas-1');   // = true !!!


// Check Cache after unload
console.log([...Cache.keys()]); 
// = ['logoSkeleton-logoAtlas-1']
// ! Unload did not remove 'logoSkeleton-logoAtlas-1' from Cache


// STEP 4 — Create second Spine instance,
// still works because 'logoSkeleton-logoAtlas-1' is in Cache,
// even though original assets were unloaded
spine2 = Spine.from({
  skeleton: 'logoSkeleton',
  atlas: 'logoAtlas'
});

I would expect that unloading a bundle remove all related assets.
Why is this not the case? Do I need to implement a workaround?
I’ve confirmed that this works, but it doesn’t seem maintainable or flexible for a larger codebase:

Cache.remove('logoSkeleton-logoAtlas-1');

Hello! A tiny phone screen gets extremely exhausting after a long day at the office. I decided to cast my browser to my smart television and loaded up playjonny casino. The high definition live dealer stream looked spectacular on the big screen without any pixelation. I secured a nice win and the payout was processed super fast. Wish you all the best and big profits

Hey! This is actually expected behavior, even if it feels like a memory leak.

Here is exactly what is happening: When you call Spine.from(), the plugin parses your raw files into a SkeletonData object. To make spawning future instances faster, it automatically caches this parsed data under that new, generated key (logoSkeleton-logoAtlas-1).

Because this new key was created dynamically by the Spine plugin and was never explicitly defined in your preloader bundle, Assets.unloadBundle() has absolutely no idea it exists. It only unloads the raw assets it knows about, leaving the parsed Spine data behind in the global Cache.

Unfortunately, yes, you will need a workaround. Instead of hardcoding the exact string, the most maintainable approach is to write a small helper function that runs right after unloadBundle. Just have it filter Cache.keys() for any strings containing your base Spine asset names (like logoSkeleton) and remove them.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...