Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot spawn more than one thread #10

Closed
hatala91 opened this issue Aug 21, 2021 · 6 comments
Closed

Cannot spawn more than one thread #10

hatala91 opened this issue Aug 21, 2021 · 6 comments

Comments

@hatala91
Copy link

hatala91 commented Aug 21, 2021

Description
I am using phaser-on-nodejs for implementing an authoritative server instance of a multiplayer online game. There might be multiple games in parallel, which is why I need multiple instances of the server and I was hoping to solve this with multithreading.

How to reproduce
Assuing I have a working phaser-on-nodejs game working with an entry script called game.js, I spawn the server side code using something like:

import { Worker } from "worker_threads";
const gameProcess = new Worker(`game.js`, {
  workerData: gameParameters,
});

With the first thread this works fine, however on spawning a second thread I get:

Error: Module did not self-register: '/Users/sebastianhatala/dev/realtime-multiplayer-pong-backend/node_modules/canvas/build/Release/canvas.node'.
Process exited with exit code 1
@yandeu
Copy link
Member

yandeu commented Aug 21, 2021

Looks like the error has something to do with node-canvas. Have you already check the node-canvas repo?

Maybe this helps: Automattic/node-canvas#1718

@hatala91
Copy link
Author

Thanks for looking into this, turns out that the causing issue is indeed node-canvas but another issue: Automattic/node-canvas#1394

Closing this, though of course a canvas independent implementation would be amazing - maybe with Phaser 4.

@yandeu
Copy link
Member

yandeu commented Sep 11, 2021

👍🏻


Btw, I was experimenting with a Standalone Arcade Physics lib.
Maybe it helps https://github.com/yandeu/arcade-physics_dev

@hatala91
Copy link
Author

Yes! Appreciate this so much since there seems to be no great standalone Node.JS physics engine out there (P2 and Matter.js seem abandoned) others are really small and barely used 🤔

@yandeu
Copy link
Member

yandeu commented Sep 11, 2021

No, matter.js is not abandoned. It's my favorite 2d physics engine.

@hatala91
Copy link
Author

Okay, glad to hear that too! I had read that somewhere (cannot have been a credible source though) and the open issues/ PRs did not directly contradict it. But we are way off topic here now anyway 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants