pixijs: Bug: Facebook Sdk Initialization Error

Current Behavior

When try to add script like

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId            : 'your-app-id',
      xfbml            : true,
      version          : 'v18.0'
    });
  };
</script>
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script>

I got error:

Uncaught (in promise) TypeError: Path must be a string. Received undefined

from @pixi/utils/lib/path.mjs

Expected Behavior

I don’t think that this is because Facebook API, because this API is used commonly over the world.

Steps to Reproduce

Just do instruction from the link

If I download this script and import it manually I got same error, why pixi throws error for an external script?

Environment

  • pixi.js version: 7.2.4*
  • Browser & Version: Chrome, Firefox
  • OS & Version: Windows 11

Possible Solution

No response

Additional Information

No response

About this issue

  • Original URL
  • State: open
  • Created 6 months ago
  • Comments: 22 (22 by maintainers)

Most upvoted comments

Nice, both of them solved the issue, I can use these for quick fix.

I mean, Object.freeze(Object.prototype) before window.fbAsyncInit = function() { ...

This is the code likely where this is happening:

https://github.com/pixijs/pixijs/blob/abecc358a0ce73fc301611ca5c2eecfd3dc7c38f/packages/assets/src/resolver/Resolver.ts#L651-L656

There are other ways we could write this which would exclude things on the prototype.

//assets.ts

import manifest from "./manifest.json";
import { Assets } from "pixi.js";

.
.
.
export async function initAssets() {
await Assets.init({ manifest });
const assets = await Assets.loadBundle(["fonts", "default", "sounds", "shop"]);
.
.
.
}

image