kaboom
kaboom copied to clipboard
Every sprite image loads twice in Safari
Version
No response
What browsers are you seeing the problem on?
Safari
What happened?
Any sprite loads twice in Safari browser. Highly likely, it happens due to the following lines of code in kaboom.ts:
// wrapper around image loader to get a Promise
function loadImg(src: string): Promise<HTMLImageElement> {
const img = new Image();
img.src = isDataURL(src) ? src : assets.urlPrefix + src; // first load
img.crossOrigin = "anonymous"; // second load
...
What's the expected behavior?
Each sprite should load only once in any browser including Safari.
Minimum reproducable code
kaboom()
loadSprite('test', 'test.png') // it doesn't matter if image file actually exists
Live demo
No response
Hmm, so strange, @slmjkdbtl check it when you can!
Btw, when I swap these two lines of code then issue disappears:
img.crossOrigin = "anonymous"; // no src url yet, so no load possible
img.src = isDataURL(src) ? src : assets.urlPrefix + src; // first load
Very weird, but yeah your fix does work, thanks! The change is merged to master.