Code Monkey home page Code Monkey logo

Comments (15)

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024 2

I apologize for not considering Node.JS environment in that PR! I'll fix this issue soon.

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024 1

pixi.js does not run natively in Node.js, it's browser only. If you need to run in Node.js, you can use this project: https://github.com/pixijs/node

from pixijs.

bhousel avatar bhousel commented on April 28, 2024 1

Thanks @bigtimebuddy , and sorry for the noise..
I tracked it down to an unneeded import * as PIXI from 'pixi.js'; from some code that was expected to run headless.

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024 1

@notchris extract.canvas doesn't work in Node. You need to use extract.pixels or extract.base64 instead.

from pixijs.

notchris avatar notchris commented on April 28, 2024 1

@notchris extract.canvas doesn't work in Node. You need to use extract.pixels or extract.base64 instead.

I'm referencing the official example: https://github.com/pixijs/node, but that's good to know. Should that be updated as well? I'm going to try out .pixels now!

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

No worries!

from pixijs.

shipurjan avatar shipurjan commented on April 28, 2024

I still have this problem in a Tauri app with NextJS (everything is configured to be client-side). Everything worked on pixi.js 7.3.3, but after updating to 7.4.0 it still works correctly, but I get an error

 node_modules\.pnpm\@[email protected]_@[email protected]\node_modules\@pixi\assets\lib\_virtual\checkImageBitmap.worker.mjs (20:29) @ Worker
 ⨯ ReferenceError: Worker is not defined
    at __webpack_require__ (C:\Users\niar-windows\Documents\repos\bioparallel\.next\server\webpack-runtime.js:33:42)

Also the project can't be build, because Worker is not defined, and even though everything is configured to be on the client-side it still seems to check if everything functions on SSR or something

EDIT:
I lazy loaded the component using pixi.js with

const Dashboard = dynamic(
    () =>
        import("@/components/tabs/dashboard/dashboard").then(
            mod => mod.Dashboard
        ),
    { ssr: false }
);

And now it seems to work without errors. So it's not a pixi problem

from pixijs.

vincaslt avatar vincaslt commented on April 28, 2024

I seem to be getting this exact issue on Electron, running on the Main (node) process, and I'm using the node package. Seems like some juggling around worker files might have introduced this issue? pixijs/node#15

Edit: my thinking is after the PR below the worker code is imported where before during the build now, where before it was encoded as string and loaded as-needed. The pixi/node seems to work by letting pixi load whatever extensions it needs and then unloading those that aren't compatible with node. Problem is that the code is not eliminated and the class is created up-front, not on-demand so the loader adds a class that tries to extend Worker class that doesn't exist in node, and the code is run, even though it would get unloaded later in the node package.

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

PR that affected Workers is here #9399
@SuperSodaSea do you think you could you take a look at this?

from pixijs.

notchris avatar notchris commented on April 28, 2024

@SuperSodaSea Thank you!

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

I wonder if we can keep the external worker.ts files (and all the type checking and linting benefits of that), but import and inline the code as a string. So we aren't shipping external worker files.

from pixijs.

notchris avatar notchris commented on April 28, 2024

@bigtimebuddy Not sure if it's a side effect of manually patching Worker to see if I could get around the issue, but I started getting similar errors about document

from pixijs.

bigtimebuddy avatar bigtimebuddy commented on April 28, 2024

@notchris can you call out those document issues? Sure we can get that sorted too.

from pixijs.

notchris avatar notchris commented on April 28, 2024

@bigtimebuddy Sure thing - it's actually not document, that was my mistake. The issue comes from extract method on app.renderer

/Users/notchris/Desktop/nodesdl-pixi/node_modules/@pixi/extract/src/Extract.ts:173
const imageData = new ImageData(new Uint8ClampedArray(pixels.buffer), width, height);
ReferenceError: ImageData is not defined

from pixijs.

SuperSodaSea avatar SuperSodaSea commented on April 28, 2024

I wonder if we can keep the external worker.ts files (and all the type checking and linting benefits of that), but import and inline the code as a string. So we aren't shipping external worker files.

Currently the worker code is already inlined as a string (see WORKER_CODE in @pixi/assets/lib/_virtual/checkImageBitmap.worker.mjs), so we won't have any extra external worker file (for example, you can see the worker code in dist/pixi.js).

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.