berstend / puppeteer-extra

💯 Teach puppeteer new tricks through plugins.
https://extra.community
MIT License
6.24k stars 732 forks source link

Worthless to use headless ? #241

Open momala454 opened 4 years ago

momala454 commented 4 years ago

As there are a lot of differences that allow websites to detect headless chrome and as we can install like x server on a server, what is the benefit of headless ? How much more ressource having headless true vs false ?

1nVitr0 commented 4 years ago

I don't think this is an issue topic for this repository, as it's more of a general question about headless browsers. Maybe it would be more fitting on StackOverflow (or even a more specific StackExchange subforum). I'll still give you my take in the issue:

For me it's mostly a tab management issue when headless is false. Since Chrome has decided it's a good idea to throttle background tabs, handling multiple tabs without headless has become close to impossible. Yes, there are flags that supposedly keep background tabs and windows active, but I still experience random things like indefinite loading, script execution pausing, click() never resolving or timers not working.

Another reason to use headless is, that it can make a server unusable when tens of chromium instances are open, making features like Alt+Tab pretty much useless. It's often desirable to have a single program that contains all the puppeteer script and not having to worry about accidentally closing a window, clicking something or breaking the testing / scraping process in any other way.

Performance wise I have not really had issues and I don't think it has much of an impact. But also keep in mind that on headless servers, headless chrome is often the only option.

momala454 commented 4 years ago

i thought you could install x on any server to make chrome headful working ? i know this may not look like directly related to puppeteer-extra, but the main goal of the stealth plugin is to hide the headless state

berstend commented 4 years ago

Even with headful usage of puppeteer will leak through a bit and needs to be fixed (check the screenshots in the stealth plugin readme). :-)

I've mentioned the pros/cons between headless/headful in various comments, but it could be worth documenting a canonical reference in the wiki (also with instructions how to setup a pseudo X server using xfvb in e.g. a docker container).

but the main goal of the stealth plugin is to hide the headless state

This is correct, headful usage requires more resources and is harder to operate - hence headless is often more desired.

moltar commented 3 years ago

I personally had never had a real world use case yet where I needed a headful setup. I've always used headless.

evading-bot-detection commented 3 years ago

Headless uses far less resources and can be run on remote servers so it is more efficient for sure.

I can run about 3x more headless browsers than headful on the same PC.