puppeteer-extra icon indicating copy to clipboard operation
puppeteer-extra copied to clipboard

Worthless to use headless ?

Open momala454 opened this issue 5 years ago • 5 comments

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 ?

momala454 avatar Jul 04 '20 15:07 momala454

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.

1nVitr0 avatar Jul 05 '20 08:07 1nVitr0

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

momala454 avatar Jul 05 '20 09:07 momala454

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.

berstend avatar Jul 06 '20 20:07 berstend

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

moltar avatar Jul 12 '20 06:07 moltar

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.

evading-bot-detection avatar Jul 15 '20 05:07 evading-bot-detection