pixijs / pixijs

The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
http://pixijs.com
MIT License
43.7k stars 4.77k forks source link

Bug: [Assets] path containing period does not load correctly #9393

Closed SerG-Y closed 9 months ago

SerG-Y commented 1 year ago

Current Behavior

Hi guys. When I am trying to load the file by url like http://0.0.0.0:8080/games/game3.0/resources/config.json pixi.js looking for it in http://0.0.0.0:8080/games/resources/config.json. Is it correct behavior? I think the reason is that game3.0 in the base path http://0.0.0.0:8080/games/game3.0 is recognized as an extension name and removed. https://github.com/pixijs/pixijs/blob/00009c14d64e3b15b900977ee188c3613f1ffa04/packages/utils/src/path.ts#L307

Expected Behavior

File loads correctly

Steps to Reproduce

Try to load any file that contains a dot in the path.

Environment

Possible Solution

No response

Additional Information

No response

amicoderozer commented 1 year ago

I have the same problem, if the build folder contains the build version (e.g. 3.0.0) Pixi doesn't load the assets correctly. If I remove the version, it works. I tried with old pixi version (4.8.5) and it works as expected!

nouakam commented 1 year ago

My team encountered the same problem. Our deadlines coming up quickly, we had to revert to Pixi 6.5 to make things work for our game project.

My understanding is that this issue comes from the new Pixi.Assets module. We have 3 distinct issues on Pixi 7+

SuperSodaSea commented 1 year ago

It seems to be introduced in #8614. In my opinion we should not remove the filename based on its "extension" in the join() / toAbsolute(), but remove it if needed manually before calling them.

adevart commented 1 year ago

I also had an issue with this in production builds with version numbers. I used a patch to ignore moving to the parent if the extension found matched a version number pattern in the URL. In the following code, I added a check if there was a version number:

https://github.com/pixijs/pixijs/blob/dev/packages/utils/src/path.ts#L316

const urlFileExtension = this.extname(prevArg);
const isVersionNumber = urlFileExtension.match(/\.[0-9]+/);

if (urlFileExtension && !isVersionNumber) {
    joined += `/../${arg}`;
} else {
    joined += `/${arg}`;
}

It's unlikely that a file will have a numeric extension so this should work for both scenarios.

For people having the issue in current production builds, you can patch the function without forking the library. Reassign the function PIXI.utils.path.join to the patched function code before using the loader.

SerG-Y commented 10 months ago

Hi, sorry for bothering @bigtimebuddy any updates on this one?

SerG-Y commented 10 months ago

@bigtimebuddy thank you for your attention to this issue. I had some time to fix it, and I hope it will work. You can remove the bounty from this issue and save it for something more important :)