Loading multiple spritesheet JSONs with related_multi_packs linking to each other can cause PIXI.Assets.load() to deadlock and never resolve
See original GitHub issueExpected Behavior
When loading multiple spritesheets that link to each other with related_multi_packs, it should be able to load them all without deadlocking.
Current Behavior
If you try to load multiple spritesheets that use TexturePacker’s related_multi_packs in its JSON file and that link to each other, it will attempt to load them even if they are already being loaded by another spritesheet, causing a deadlock.
{"frames": {
...
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "my-numbers-0.png",
"format": "RGBA8888",
"size": {"w":512,"h":512},
"scale": "1",
"related_multi_packs": [ "my-numbers-1.json", "my-numbers-2.json" ],
"smartupdate": "$TexturePacker:SmartUpdate:ea7b985de3af11d8d7e7bff73b074569:80778496bccc42d13437c459447a7090:06d8674a9e41fa7741f7530a3f8cb3c3$"
}
}
const spritesheets: string[] = [
"assets/my-numbers-0.json",
"assets/my-numbers-1.json",
"assets/my-numbers-2.json",
]
console.log("Trying to load spritesheets all in a single load()...");
await Assets.load(spritesheets);
console.log("Never reached!");
Possible Solution
Either the user has to carefully make sure to load multi-pack spritesheets one by one, in case it links to another spritesheet and loads it automatically, or the asset loader should implement a check to make sure it is not already loading that spritesheet so it doesn’t deadlock itself.
Steps to Reproduce
- Download, extract and run the barebones demo project linked below (“npm i”, “npm run local:buildRun”)
- Open the webpage and check the console to see that “Never reached!” is never printed.
- Comment out test_one() and uncomment test_two() to see that the promises never resolve even when loading spritesheets individually all at once.
Environment
pixi.js
version: 7.0.3 & also affecting 6.5.8- Browser & Version: Edge Version 107.0.1418.35, Chrome Version 107.0.5304.88 (Official Build) (64-bit), Firefox 106.0.4 (64-bit)
- OS & Version: Windows 11
- Running Example: related_multi_packs_bug_demo.zip
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
PIXI.loader and multiple sprite sheets/json files - best practices
Currently I'm making two arrays each containing multiple JSON files with sprite sheet data. This works, but I'm having to call two separate ......
Read more >Loading Pixi spritesheets from TexturePacker manually and ...
Loaded json files with axios. Looped through the multipack files and made sure the correct json and spritesheet was grouped together in an...
Read more >TexturePacker Download - Newest releases and betas
Download the newest release of TexturePacker for Windows, MacOS and Linux. ... Improved the layout of the sprite sheet preview for a better...
Read more >Assets - PixiJS
The Assets package is a modern replacement for the old PIXI.Loader class. It is a promise-based resource management solution that will download, cache...
Read more >PIXI.Assets - PixiJS API Documentation
Do not be afraid to load things multiple times - under the hood, it will NEVER ... It's hard to know what resolution...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m trying to solve this problem 😃
Animations across multiple spritesheets is an open issue see #7000.
Concatenating multiple spritesheets into a single Spritesheet object would likely solve this, we could then merge animations with the same key.