Xetera / ghost-cursor

🖱️ Generate human-like mouse movements with puppeteer or on any 2D plane
MIT License
1.11k stars 120 forks source link

Using more 5-10 browser instances in one time #92

Open smmwsem opened 1 year ago

smmwsem commented 1 year ago

Hello. I have an issue with cursor when I'm using it on 5-10 parallels puppeteer instances. I just starting 5 workers in one time with puppeteer and see that cursor is lagging on each browser.

Look at example: https://gist.github.com/smmwsem/b34292ed98df0ed36e5a7cfa2058fb28

Just run main.js

You need to install dependencies:

Try just one thread and five threads.

The main question is how to work with multiple browsers at the same time?

Thanks.

Xetera commented 1 year ago

Does your code behave the way you expect without ghost cursor? There's currently no explicit support for multiplexed browsers. There are quite a few random numbers involved in the path generation algorithm using Math.random so running multiple copies of it will probably get you slightly different results which could explain some of the lag.

Though I have to wonder why you need everything to line up exactly on each browser in the first place. If there's a reasonable usecase for what you want, the Math.random calls could be replaced with a seedable PRNG like mersenne twister.

But even with library support, you're going to have to do some sort of synchronization across workers to make sure they're all ready to go after each page load. And I imagine your browsers are going to start drifting out of sync over time regardless.

smmwsem commented 1 year ago

@Xetera Hello, the code runs much slower when multiple browsers are launched.

Look how fast the cursor moves on 1 video and how slow the cursors move when 5 copies are running.

https://drive.google.com/file/d/1ss3Du4GEilL8izuKuTMEYUaAmpnPwg4l/view?usp=share_link https://drive.google.com/file/d/1HHJNCQsuKMezjzxJ5Jedir3VR8mVuew2/view?usp=share_link

smmwsem commented 1 year ago

@Xetera hi. Do you have ideas about my issue? Thanks.

JackSparrowf9 commented 3 months ago

Do you find solution for this, I run 3 4 browser instances and it lag, any idea?