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

CLI flag to choose whether to open a new lighthouse page or not #16259

Open
Shivam93937 opened this issue Nov 25, 2024 · 9 comments
Open

CLI flag to choose whether to open a new lighthouse page or not #16259

Shivam93937 opened this issue Nov 25, 2024 · 9 comments
Assignees

Comments

@Shivam93937
Copy link

Shivam93937 commented Nov 25, 2024

Feature request summary

A CLI flag (something like --reuse-page) to re-use the existing page that was running on the browser that puppeteer connects to.
The page can be selected from await lhBrowser.pages().

Are you willing to work on this yourself?
Yes

What is the motivation or use case for changing this?
It will help run lighthouse programmatically inside applications like CEF and Electron where opening a new page (by default) causes a failure when connecting to it through remote debugging port.

How is this beneficial to Lighthouse?
It will widen the audience to which lighthouse can be used and increase the tool's users.

Mentioned the changes in the screenshot:
lh module changes

@adamraine
Copy link
Member

This should be possible already with the Node API: https://github.com/GoogleChrome/lighthouse/blob/main/docs/puppeteer.md#option-1-launch-chrome-with-puppeteer-and-handoff-to-lighthouse

Is there a use case where you need to use the CLI and can't use the Node API?

@Shivam93937
Copy link
Author

@adamraine I need to use the functionalities provided by lighthouse CI, (is-median runs, multiple runs, etc.) I cannot use node API if I want to use LIghthouse CI.

@adamraine
Copy link
Member

Gotcha. I think a solution in Lighthouse CLI could be tricky because the CLI can still connect to an existing browser instance with multiple tabs open. Maybe a quick solution would be to re-use a page if it's the only page open.

@Shivam93937
Copy link
Author

Yes agreed, this is the solution i proposed and I need a CLI flag for this, or I will have to fork and maintain the mono repo lhci and lighthouse too.

@Shivam93937
Copy link
Author

@adamraine
Is there any update on this discussion?
Should I provide a CL which can do the following, we will require changes both in lhci and lighthouse modules.
Adding this functionality will allow lighthouse to be run on Chromium Embedded Framework.
I think the best way is to pass a CLI Flag, if we want to limit it to Single Page only, or execute a new page.

@Shivam93937
Copy link
Author

@brendankenny Any opinions from your side?

@adamraine
Copy link
Member

We are going to accept this proposal, add a --reuse-page or something.

Ideally, we could modify lighthouse CI to allow testing via the Node API so that a specific puppeteer page can be used, but that will be a much larger change than what is proposed here.

@Shivam93937
Copy link
Author

Image

These changes in the lhci module does it for me and I am able to run lhci and also integrate a puppeteer script.

@Shivam93937
Copy link
Author

Also, do we have a timeline for this feature?

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

No branches or pull requests

4 participants