GithubHelp home page GithubHelp logo

Comments (22)

talhaozdemir avatar talhaozdemir commented on April 28, 2024 1
//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

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024 1

This is the code likely where this is happening:

for (const key in results)
{
const asset = results[key];
assets[this._extractAssetIdFromBundle(bundleId, key)] = asset;
}

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

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024 1

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

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024 1

@bigtimebuddy Perhaps we could consider adding guard-for-in to our @pixi/eslint-config?

https://github.com/pixijs/eslint-config/blob/0bc65621ec0fc2e477f1c060ceb6a94b8975e5ac/index.js#L66

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024 1

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

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

Can you show how you import and use PixiJS? It would be nice if you could provide a full stack trace of the errors.

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

I logged the paths, they may help you.

image

image

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

If I remove Facebook SDK from index.html, undefined consoles disappear that above picture.

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

Maybe try debugging at the promises call in the stack. See what the assetsToLoad looks like.

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

Here it is;

with Facebook SDK
image
without
image

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

I also need to mention that sometimes it doesn't give the error in Chrome, and the application opens, but it always gives the error in Firefox.

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

Looks like the Facebook SDK injected the array somewhere 🤔

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

Wow, that is wild. I agree that it sounds like some prototype stuffing via Facebook SDK.

If you can track down where in Assets those extra keys are added, it might give us a clue. If you do console.log([], Array.prototype, {}, Object.prototype) and see if that has getParams, getConfig, etc? Can you repro this outside Pixi?

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

these?

image

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

I don't think that I can reproduce this issue outside of Pixi. On the other hand, I run it under the Facebook URL as a localhost. I mean the url is like:

https://www.facebook.com/embed/instantgames/1111111111111111/player?game_url=https%3A%2F%2Flocalhost%3A8080

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

That's super annoying on Facebook's part.

One idea is that we might want to use Object.create(null) instead of {} which would remove any prototype-chain and insulate us from this issue. There are a bunch of areas in Assets that do this type of assignment. For example:

const out: Record<string, Record<string, any>> = {};

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

As a workaround, maybe you can try to Object.freeze(Object.prototype) before everything?

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

For instance, Object.getOwnPropertyNames(results) would give us more stable results.

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

I have both tried Object.create(null) and Object.freeze(Object.prototype). The error appears in both cases.

image

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

@bigtimebuddy I tried your last suggestion:

image

and I got a different error

image

from pixijs.

talhaozdemir avatar talhaozdemir commented on April 28, 2024

@SuperSodaSea in your case: Object.freeze(Object.prototype) before window.fbAsyncInit = function() { ...

I get TypeErrors:

image

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

What about Object.seal(Object.prototype) or Object.preventExtensions(Object.prototype)?

from pixijs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.