CreateJS / PreloadJS

PreloadJS makes preloading assets & getting aggregate progress events easier in JavaScript. It uses XHR2 when available, and falls back to tag-based loading when not.
http://createjs.com/
MIT License
2.88k stars 761 forks source link

LoadQueue gets messed up with duplicate "src" items loaded in other queues #274

Open cmam opened 3 years ago

cmam commented 3 years ago

Issue Details

1.0.1

When having multiple LoadQueue instances, if manifests contain the same file, or the same file with different ID is loaded on a queue, the queue progress is >= 1, causing relevant checks to fail (e.g. is my sound queue ready?). This means that, per queue, the numItems is less than numLoadedItems resulting in the loaded property being false and progress being something greater than 1.

What's concerning is that if I load a manifest on another queue, the "original" queue that happens to have loaded a file from that manifest (i.e. same "src" property), gets messed up as described above.

Example:

m1 = [ {src: 'path/sound.ogg', id: 's1' } ];
m2 = [ {src: 'path/sound.ogg', id: 's2' } ];

q1 = new createjs.LoadQueue(true);
q1.installPlugin(createjs.Sound);

q2 = new createjs.LoadQueue(true);
q2.installPlugin(createjs.Sound);

q1.loadManifest(m1);

q1
// All seem good.
loaded: true
progress: 1
numItems: 1
numItemsLoaded: 1

// Load the manifest on the other queue.
q2.loadManifest(m2);

q1
// It gets messed up, for every loadManifest run on any other queue, even though I specify different ID.
loaded: false
progress: 2
numItems: 1
numItemsLoaded: 2

q2
loaded: true
progress: 1
numItems: 1
numItemsLoaded: 1

I hope it makes sense. I guess this has something to do with the global sound registering part, recognizing already loaded "src" paths, but I expect it shouldn't affect the other load queues.

Debian Testing, Google Chrome 91.0.4472.114.

None, other than having to create duplicate files in different paths in order to avoid this.

danzen commented 1 year ago

This does make sense. If you can dig into the preloadjs code and see what can be done to avoid it, that would be great. The main devs are on to other things but we are doing our best to maintain issues - somewhat as a community. So ideally, that would be through a pull request. Cheers.