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

proposal: do not start a browser in headless mode by default #845

Open
ZekeLu opened this issue Jun 3, 2021 · 0 comments · May be fixed by #848
Open

proposal: do not start a browser in headless mode by default #845

ZekeLu opened this issue Jun 3, 2021 · 0 comments · May be fixed by #848

Comments

@ZekeLu
Copy link
Member

ZekeLu commented Jun 3, 2021

Background

This was suggested by @kenshaw in a private talk.

The purpose is to make it easy for new comers. As of now, we dedicated the first question in the Q&A section for this case:

I can't see any Chrome browser window

By default, Chrome is run in headless mode. See DefaultExecAllocatorOptions, and an example to override the default options.

But that example just shows how to override the default options, it does not show how to disable the headless mode.

The chromedp.Headless option is just for enabling the headless mode; to disable the headless mode, the user should specify this option:

  • chromedp.Flag("headless", false)

And maybe the following two options too:

  • chromedp.Flag("hide-scrollbars", false)
  • chromedp.Flag("mute-audio", false)

That is not so obvious for a new comer.

This is a breaking change. So I'm filing this issue in the hope that the current users of chromedp will be aware of this change.

Changes

We will remove the chromedp.Headless option from the chromedp.DefaultExecAllocatorOptions.

Affected Users

All users that want to use chromedp in headless mode will be affected. The good news is that some customized browsers already run in headless mode even without the --headless option. chromedp/headless-shell is among such kind of browsers. So the chromedp/headless-shell users won't be affected by this change.

The affected users have to do something like this after the change:

opts := append(chromedp.DefaultExecAllocatorOptions[:],
	chromedp.Headless,
	// other options below
)
actx, acancel := chromedp.NewExecAllocator(context.Background(), opts...)
defer acancel()
ctx, cancel := chromedp.NewContext(actx)
defer cancel()

Otherwise, the browser will fail to start in headless environment with errors like this:

2021/06/03 06:35:49 chrome failed to start:
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
ZekeLu added a commit to ZekeLu/chromedp that referenced this issue Jun 4, 2021
@ZekeLu ZekeLu linked a pull request Jun 4, 2021 that will close this issue
ZekeLu added a commit to ZekeLu/chromedp that referenced this issue Jul 13, 2021
@ZekeLu ZekeLu mentioned this issue Jul 23, 2023
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

Successfully merging a pull request may close this issue.

1 participant