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

Fix CLI and use old headless by default in chromium based browsers #157

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

satheler
Copy link
Contributor

@satheler satheler commented Sep 2, 2024

fix #156
fix #155

Reference links

Note: Passing the --headless command-line flag without an explicit value still activates the old Headless mode, but we intend to change this default. We intend to remove the old Headless from the Chrome binary and stop supporting this mode in Puppeteer in 2024. Simultaneously, we'll make old Headless mode available as a standalone binary for users who can't upgrade yet.

The moment mentioned in the quote above has arrived.

@satheler satheler changed the title Fix CLI and use old headless by defaul in chromium based browsers Fix CLI and use old headless by default in chromium based browsers Sep 2, 2024
@satheler
Copy link
Contributor Author

satheler commented Sep 2, 2024

@vgalin review please

@vgalin vgalin changed the base branch from master to develop September 3, 2024 11:43
Copy link
Owner

@vgalin vgalin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, you could consider keeping the comma at the end of the line, it makes diffs cleaner for current and future commits on this line.

Copy link
Owner

@vgalin vgalin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you use a shorter name for the should_use_new_headless_mode attribute ? Maybe use_new_headless_mode, or even use_new_headless.

@vgalin
Copy link
Owner

vgalin commented Sep 3, 2024

Thank you for taking the time to create this PR. Along with the (minor) reviews, I have a question myself:

What happens if a user is using an older version of Chrome(ium)? Does it break the headless mode because headless=new|old is used instead of just headless, or does it still work fine?

Regardless of the outcome, I see two possible courses of action:

  • Do nothing: If someone is using an older Chrome version, they’ll need to use an older version of html2image as well.
  • Allow the user to choose between headless=new, headless=old, and headless. Currently, the attribute you added sets headless to headless=new or headless=old based on its truthiness. Perhaps a third option could be introduced: if the attribute is None, then the value is simply headless without any suffix.

Do as you see fit, I don't have a preference at the moment. If I change my mind, I can always add the second option later.

@jrb-github
Copy link

jrb-github commented Sep 3, 2024

So does this mean the browser_executable parameter is no longer supported? Is there an intended retrofit for those of us who were using that (to use Edge instead of Chrome)? Thanks!

@vgalin
Copy link
Owner

vgalin commented Sep 3, 2024

@jrb-github Not exactly. This only concerns the CLI script of html2image, and browser_executable has been removed because it was wrongly used as a parameter of the screenshot method, which no longer supports this parameter.

If you're only using html2image through Python files/scripts and not through the CLI, nothing changes for you. If you're using the CLI, it will "just" become functional again.

@jrb-github
Copy link

jrb-github commented Sep 3, 2024

@jrb-github Not exactly. This only concerns the CLI script of html2image, and browser_executable has been removed because it was wrongly used as a parameter of the screenshot method, which no longer supports this parameter.

If you're only using html2image through Python files/scripts and not through the CLI, nothing changes for you. If you're using the CLI, it will "just" become functional again.

Hm. Maybe I should branch this off into a separate issue, but I found this pull request because of a recent change in behavior where I was successfully using the browser_executable parameter in the Html2Image constructor (python code, not CLI), and when using the screenshot method on the resulting object, it no longer generates the correct image. Obviously I'm not using this code as the change hasn't been committed yet, but it seemed so closely-related in timeframe and behavior that I assumed it must be connected.

EDIT - I assume based on your comments that the behavior I'm seeing is unrelated. I submitted a new issue here.

@satheler
Copy link
Contributor Author

satheler commented Sep 4, 2024

@vgalin Thanks for the review!!! I believe the best way is to leave it backwards compatible anyway.
I made the changes as you suggested on 9e96083

@vgalin vgalin merged commit da4bd04 into vgalin:develop Sep 9, 2024
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 this pull request may close these issues.

The screenshot of page is not full page [Bug] Unable to Use Command hti -U
3 participants